From: kylix <likai3g@gmail.com>
Subject: Fixed Point number mul, is it a bug?
Date: Thu, 18 Oct 2012 00:11:32 -0700 (PDT)
Date: 2012-10-18T00:11:32-07:00 [thread overview]
Message-ID: <422cd822-6d9a-4909-9009-995d845180b8@googlegroups.com> (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.
next reply other threads:[~2012-10-18 7:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 7:11 kylix [this message]
2012-10-18 7:35 ` Fixed Point number mul, is it a bug? 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox