comp.lang.ada
 help / color / mirror / Atom feed
* Trouble with s'fraction attribute.
@ 2002-09-28 20:01 gilrain
  2002-09-28 20:18 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 3+ messages in thread
From: gilrain @ 2002-09-28 20:01 UTC (permalink / raw)


Hi all,

I'm writing a program in which I need to seperate the integer and fractional
parts of a float. After reading some documentation, it seemed like this
should do the trick:

with ada.text_io, ada.float_text_io;
use ada.text_io, ada.float_text_io;
procedure test is
   number, int, fl : float;
begin
   number := 2.9;

   int := float'truncation(number);
   fl := float'fraction(number);

   put(int,0,0,0); new_line;
   put(fl,0,0,0);
end test;

When this is run, int truncates as expected outputs as "2.0". Good. However,
fl outputs as "0.7", which isn't at all what I expected (0.9) or wanted.
What's going on here? I expect I've somehow misunderstood what the
s'fraction attribute does; is there a standard function for what I'm trying
to accomplish?

Thanks,

John Thile






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

end of thread, other threads:[~2002-09-28 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-28 20:01 Trouble with s'fraction attribute gilrain
2002-09-28 20:18 ` David C. Hoos, Sr.
2002-09-28 21:32   ` gilrain

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