comp.lang.ada
 help / color / mirror / Atom feed
* Re: altering number of significant figures
@ 2004-09-28  6:52 Christoph Karl Walter Grein
  2004-09-28 10:26 ` David Peterson
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Karl Walter Grein @ 2004-09-28  6:52 UTC (permalink / raw)
  To: comp.lang.ada

>    myfloat : float := 1234.5678;
>    screen_display("value = " & float'image(myfloat));

> However I do not know how to only print only the first 2 (for example) 
> decimal places of myfloat.
> 
> The above will print "value = 1234.5678". However I want "value = 1234.56".

Look at RM A.10.1 (67) procedure Put to a String. There you can choose the format (digits before and after the dot, exponential digits). This rounds (1234.57).

If you really want 1234.56, you have to use the 'Floor attribute (RM K(74)).
________________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt neu bei WEB.DE FreeMail: http://freemail.web.de/?mc=021193




^ permalink raw reply	[flat|nested] 6+ messages in thread
* altering number of significant figures
@ 2004-09-28  5:59 David Peterson
  2004-09-28  6:41 ` tmoran
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: David Peterson @ 2004-09-28  5:59 UTC (permalink / raw)


Hi, sorry for this stupid question, but i can not seem to find out how to do 
it. Suppose i define:


   myfloat : float := 1234.5678;
   screen_display("value = " & float'image(myfloat));


... where screen_display() prints out the content passed to it, to standard 
output.

However I do not know how to only print only the first 2 (for example) 
decimal places of myfloat.

The above will print "value = 1234.5678". However I want "value = 1234.56".

I know there is a simple solution to this, but i cant find it. Using Barnes 
to learn from.

Any help most welcome :)
Thanks,
David 





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

end of thread, other threads:[~2004-09-28 17:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-28  6:52 altering number of significant figures Christoph Karl Walter Grein
2004-09-28 10:26 ` David Peterson
  -- strict thread matches above, loose matches on Subject: below --
2004-09-28  5:59 David Peterson
2004-09-28  6:41 ` tmoran
2004-09-28  6:51 ` Martin Krischik
2004-09-28 17:58 ` Jeffrey Carter

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