comp.lang.ada
 help / color / mirror / Atom feed
* Fixed Point number mul, is it a bug?
@ 2012-10-18  7:11 kylix
  2012-10-18  7:35 ` Vinzent Höfler
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: kylix @ 2012-10-18  7:11 UTC (permalink / raw)


-- GNAT GPL 2012 
with Ada.Text_IO;
procedure FixPoint is
   type FP is delta 0.01 range 0.00 .. 99.99;
   -- type FP is delta 0.01 digits 4;
   x : FP := 0.01;
begin
   for i in 1 .. 5 loop
      x := x * 2;
      Ada.Text_IO.Put_Line("x =>" & FP'Image(x)); 
   end loop;
end Fixpoint;

In my machine, it yield results:

x => 0.02
x => 0.03
x => 0.06
x => 0.13
x => 0.25

Why not: 0.02 0.04 0.08 0.16 0.32 ?

If FP declared as "type FP is delta 0.01 digits 4",
it yield expected results.





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

end of thread, other threads:[~2012-10-28  2:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18  7:11 Fixed Point number mul, is it a bug? kylix
2012-10-18  7:35 ` Vinzent Höfler
2012-10-18 14:49   ` Adam Beneschan
2012-10-19  9:09     ` AdaMagica
2012-10-18  7:57 ` Dmitry A. Kazakov
2012-10-18 10:34   ` Georg Bauhaus
2012-10-18 10:42   ` Ian Clifton
2012-10-18 12:37     ` Dmitry A. Kazakov
2012-10-19 22:58       ` Ian Clifton
2012-10-18 14:40     ` Adam Beneschan
2012-10-18 14:04 ` Shark8

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