comp.lang.ada
 help / color / mirror / Atom feed
* Truncating a fixed-point value
@ 2010-07-09 19:06 Adam Beneschan
  2010-07-09 20:34 ` Simon Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Adam Beneschan @ 2010-07-09 19:06 UTC (permalink / raw)


I must be suffering from an embarrassing mental block, because I'm
sure there's a simple solution, but I can't see what it is.

I have a value X of a fixed-point type, X >= 0.0, and I need to
compute Floor(X) as an Integer.  'Truncation and 'Floor aren't defined
for fixed-point types; the type conversion Integer(X) rounds; and
Integer(X-0.5) fails if X=0.0.

How do others do this?  Or do I have to resort to an IF statement (or
conditional expression in Ada 2012) to handle the different cases?

               -- Adam



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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-09 19:06 Truncating a fixed-point value Adam Beneschan
2010-07-09 20:34 ` Simon Wright
2010-07-09 23:21   ` Adam Beneschan
2010-07-10  3:13     ` Gene
2010-07-11 19:43       ` Gene
2010-07-10  8:12     ` Simon Wright
2010-07-09 20:39 ` Gene
2010-07-09 21:20   ` Jeffrey R. Carter
2010-07-09 21:52   ` Adam Beneschan
2010-07-13 11:26     ` Jacob Sparre Andersen
2010-07-09 22:58 ` Shark8

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