manoj murali
manoj murali

Reputation: 41

Can anybody clarify how the resultant value is derived?

Code fragment in PL/I is given below:

DECLARE WAVE_LTH FLOAT BINARY(21);

...

WAVE_LTH = 11001E-10B (**resultant value = 0.0244140**)

Can anybody clarify how the resultant value is derived?

Upvotes: 4

Views: 160

Answers (1)

njuffa
njuffa

Reputation: 26085

The program statement in question is presumably from a PL/I program running on IBM System/360 hardware. This used a hexadecimal floating-point representation, for details see this Wikipedia article.

According to my old literature on PL/I, FLOAT BINARY(21) specifies a single-precision floating-point number on this platform. 21 specifies the effective number of mantissa bits. As this corresponds to the default value for a FLOAT BINARY operand, it could be left off. Due to the base-16 representation the most significant three bits of the 24-bit mantissa could be zero; this leaves a guaranteed 21 bits of precision.

The B suffix tells us that the floating-point literal uses base-2 representation. 11001 in binary is 25 in decimal. The exponent itself is given in decimal, so E-10 means the scale factor is 2-10. The value of this floating-point literal constant is therefore 25 / 1024 or 0.0244140.

Upvotes: 11

Related Questions