Skip to content

Number of bytes required to encode F32 #243

Answered by maxime-esa
ThibFrgsGmz asked this question in Q&A
Discussion options

You must be logged in to vote

Assuming your type is defined with this range (corresponding to a 32bits float):

MyF32 ::= REAL (-3.4e38 .. 3.4e38)

For the binary encoding you can choose between various schemes when you invoke the compiler: either uPER (ASN.1's unaligned Packed Encoding Rules) with the -uPER flag or ACN with -ACN.

For real numbers, PER is not an optimal choice because it needs at least 13 bytes whatever precision you need. In fact it theoretically provides "infinite precision" which your do not need most of the time.

So to solve your issue, first create an ACN file for your grammar (f32.asn) like this:

$ asn1scc -ACND f32.asn

Edit the file that was generated (f32.acn) and add the following directive t…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@usr3-1415
Comment options

@ThibFrgsGmz
Comment options

Answer selected by ThibFrgsGmz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants