Saturday, 14 April 2018

ASN.1: REAL: Working with decimal numbers

Type: REAL        

Description: Represent decimal point numbers.

You can represent real numbers in 2 ways.
         Decimal format like 546789.239
         Sequence format like {mantissa 546789239, base 10, exponent -3}.

Example
salary REAL

Example Schema
Employee ::= SEQUENCE {
    name VisibleString,
    id VisibleString,
    salary REAL
}

Sample data for above schema
emp Employee ::= {
 name "Rama Krishna",
 id "I123456",
 salary 546789.239
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <id>I123456</id>
  <salary>546789.239</salary>
</Employee>


Sample data for above schema using mantissa notation
emp Employee ::= {
 name "Rama Krishna",
 id "I123456",
 salary {mantissa 546789239, base 10, exponent -3}
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <id>I123456</id>
  <salary>5.46789239E5</salary>
</Employee>








Previous                                                 Next                                                 Home

No comments:

Post a Comment