简体   繁体   中英

ASN.1 REAL type includes mappings to Java BigDecimal?

I am trying to understand if the ASN.1 REAL type is meant to be mapped for Java type of float and double only ?

How about Java BigDecimal ? Is is included in ASN.1 REAL type ?

I am looking the document in the link https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf but could not understand it sufficiently for my question.

Thank you.

ASN.1 does not define the mapping to any particular programming language. It describes the "Abstract Values" and the encoding rules specify how those Abstract Values should be encoded (or serialized) when going across the line. The mapping to a particular programming language is left to the tool vendors. Since ASN.1 supports both base 2 and base 10 REAL values, good ASN.1 tools for Java will appropriately map the corresponding REAL types to float, double, or BigDecimal based on the constraints placed on the ASN.1 REAL type.

I'm not familiar with java and it's BigDecimal but ASN.1 REAL should be able to encode any floating point number.

According to section 8.5.6.4 d) of the document you pointed in the question you can encode exponent to 256 bytes (2 8 ). And that is if you are using base 2. With base 10 you are encoding text representation of your number in some normalized form ie 45.E123456788.

The REAL type consists of two distinct sets of values, those in base 10 and those in base 2. Technically, values in the two different bases that represent the same real value are still distinct REAL values. Since there are base 10 values, REAL can represent real values that cannot be represented exactly in a Java double or float (eg .1).

The REAL type is defined in X.680.

Some encoding rules (eg OER, X.696) have special rules for REAL that is constrained to what can be represented in IEEE 754 formats.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM