comp.lang.ada
 help / color / mirror / Atom feed
* Floating point representation-help
@ 2002-08-12 12:29 Ashwath
  2002-08-12 13:08 ` David C. Hoos
  0 siblings, 1 reply; 3+ messages in thread
From: Ashwath @ 2002-08-12 12:29 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-12 23:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-12 12:29 Floating point representation-help Ashwath
2002-08-12 13:08 ` David C. Hoos
2002-08-12 23:43   ` Robert Dewar

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