comp.lang.ada
 help / color / mirror / Atom feed
* Float conversion
@ 2010-07-29 12:23 Henrique
  2010-07-29 12:44 ` Jacob Sparre Andersen
                   ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Henrique @ 2010-07-29 12:23 UTC (permalink / raw)


Hi,

I have some problems in converting float variables in Ada. Look at the
code below.

Why var4 is not equal var1?

Thanks.

--
Execution results:
--

var3: =
var4: >

--
Code:
--

with Ada.Text_IO, Ada.Float_Text_IO;
use Ada.Text_IO, Ada.Float_Text_IO;

procedure Test is

  type My_Float is digits 6;

  CONVERSION_CONSTANT  : constant My_Float := 6076.11;
  CONVERSION_CONSTANT2 : constant My_Float := 1.0 /
CONVERSION_CONSTANT;

  package Float_Text_IO is new Ada.Text_IO.Float_IO (Long_Float);
  use Float_Text_IO;

  var1: My_Float := 999.9;
  var2: My_Float := var1*CONVERSION_CONSTANT;
  var3: My_Float := var2/CONVERSION_CONSTANT;
  var4: My_Float := var2*CONVERSION_CONSTANT2;
begin
  Put("var3: ");
  if var3 = var1 then
    Put("=");
  elsif var3 > var1 then
    Put(">");
  else
    Put("<");
  end if;

  New_Line;
  Put("var4: ");
  if var4 = var1 then
    Put("=");
  elsif var4 > var1 then
    Put(">");
  else
    Put("<");
  end if;
end Test;



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

end of thread, other threads:[~2010-08-07 13:49 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-29 12:23 Float conversion Henrique
2010-07-29 12:44 ` Jacob Sparre Andersen
2010-07-29 12:46 ` Dmitry A. Kazakov
2010-07-29 15:08   ` Georg Bauhaus
2010-07-29 15:10     ` Georg Bauhaus
2010-07-29 15:35     ` Dmitry A. Kazakov
2010-07-29 18:21       ` Henrique
2010-07-29 19:08         ` Jeffrey R. Carter
2010-07-29 19:15         ` Dmitry A. Kazakov
2010-07-30  1:30           ` Phil Clayton
2010-07-30  8:43             ` Dmitry A. Kazakov
2010-07-30 13:14               ` Phil Clayton
2010-07-30 14:34                 ` Dmitry A. Kazakov
2010-07-31 15:12                 ` Stephen Leake
2010-08-03  1:07                   ` Phil Clayton
2010-08-03  3:31                     ` Shark8
2010-08-03 10:38                     ` Georg Bauhaus
2010-08-04  7:27                       ` Stephen Leake
2010-08-04 16:15                         ` Georg Bauhaus
2010-08-04 16:32                       ` Phil Clayton
2010-08-04  7:26                     ` Stephen Leake
2010-08-04 12:52                       ` Robert A Duff
2010-08-04 14:32                         ` Dmitry A. Kazakov
2010-08-04 19:36                           ` Simon Wright
2010-08-04 19:46                             ` Dmitry A. Kazakov
2010-08-04 20:29                             ` Georg Bauhaus
2010-08-05 12:05                         ` Stephen Leake
2010-08-07  5:54                           ` Shark8
2010-08-07  8:56                             ` Georg Bauhaus
2010-08-07 13:49                               ` Shark8
2010-08-05 10:20                       ` Phil Clayton
2010-07-30 13:16           ` Henrique
2010-07-29 15:37   ` Warren
2010-07-29 14:56 ` Georg Bauhaus
2010-07-29 17:56   ` Jeffrey R. Carter

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