comp.lang.ada
 help / color / mirror / Atom feed
From: vashwathus@yahoo.com (Ashwath)
Subject: Floating point representation-help
Date: 12 Aug 2002 05:29:27 -0700
Date: 2002-08-12T12:29:27+00:00	[thread overview]
Message-ID: <14763faf.0208120429.658b842d@posting.google.com> (raw)

Have look at the following program 
with TEXT_IO; 
with UNCHECKED_CONVERSION; 
procedure UNCHECK_DEMO is 
package INT_IO is new TEXT_IO.INTEGER_IO(LONG_LONG_INTEGER); 
function INT_TO_FLT is 
new UNCHECKED_CONVERSION( 
SOURCE => LONG_LONG_INTEGER, 
TARGET => FLOAT); 
INT : LONG_LONG_INTEGER; 
FLT : FLOAT; 
begin 
INT:=2#11111111100000000000000000000000#; 
FLT:=INT_TO_FLT(INT); 
INT_IO.put(INT,0,2); 
end; 

Now look at the following sentences which explains how to find the
exact value of a 32 bit word (This 32 bit word is IEEE single
precision floating point standard representation).

The value V represented by the word may be determined as
follows:(Concentrate on condition 2).

1)If E=255 and F is nonzero, then V=NaN ("Not a number") 
2)If E=255 and F is zero and S is 1, then V=-Infinity 
3)If E=255 and F is zero and S is 0, then V=Infinity 
4)If 0<E<255 then V=(-1)**S * 2 ** (E-127) * (1.F) where "1.F" is
intended to represent the binary number created by prefixing F with an
implicit leading 1 and a binary point.
5)If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-126) * (0.F) These
are "unnormalized" values.
6)If E=0 and F is zero and S is 1, then V=-0 
7)If E=0 and F is zero and S is 0, then V=0 
Now in the above program I am making the float variable FLT to take
the value so as satisfy the condition 2. I was expecting exception to
be raised when i run this program(because the value should be infinity
according to condition 2), but it did'nt.
Any Idea why?Pls let me know if I am doing any stupid thing in the
program.



             reply	other threads:[~2002-08-12 12:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-12 12:29 Ashwath [this message]
2002-08-12 13:08 ` Floating point representation-help David C. Hoos
2002-08-12 23:43   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox