comp.lang.ada
 help / color / mirror / Atom feed
* Fixed Point Numbers
@ 1999-05-27  0:00 Robert I. Eachus
  1999-06-08  0:00 ` Robert A Duff
  0 siblings, 1 reply; 5+ messages in thread
From: Robert I. Eachus @ 1999-05-27  0:00 UTC (permalink / raw)


Philip Bradley wrote:
  
> The first definition is the desired definition (and compiles using
> Gnat).  Unfortunately the 2nd one is as close as I can get using a
> different compiler - one I am having to use, but not by choice!

    You should be pleased that both compilers will allow you to get what
you want, and my hat is off to GNAT for supporting the first definition.
 
> I am really only interested in the effect on the attributes, operators
> etc. of Long_type if the 2nd definition is used rather than 1st.  Does
> anyone know?
 
    In both cases you should get exactly the same representation, and
operations that use hardware overflow to do range checking, although you
may (or may not) get different values for 'Last.  The definition of
fixed point types cleverly does not require that the end points of the
specified range be values of the (sub)type.  This allows the compiler in
both cases to exclude the value +180.0 from the representable values for
the type and fit it exactly in 32-bits.  (By the rules you can also
exclude -180.0, but I would expect this only on ones-complement
machines.)
-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 5+ messages in thread
* Fixed Point Numbers
@ 1999-05-27  0:00 Philip Bradley
  1999-05-28  0:00 ` Robert Dewar
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Bradley @ 1999-05-27  0:00 UTC (permalink / raw)


What is the impact of the differing deltas in the following type
definitions :

type Long_Type is delta 180.0/2**31 range -180.0 .. 180.0;
for Long_Type'Small use 180.0/2**31;
for Long_Type'Size use 32;

and

type Long_Type is delta 256.0/2**31 range 
   -180.0 .. 180.0 - (180.0/2**31);
for Long_Type'Small use 180.0/2**31;
for Long_Type'Size use 32;


The first definition is the desired definition (and compiles using
Gnat).  Unfortunately the 2nd one is as close as I can get using a
different compiler - one I am having to use, but not by choice!

I am really only interested in the effect on the attributes, operators
etc. of Long_type if the 2nd definition is used rather than 1st.  Does
anyone know?


-- 
Philip Bradley




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

end of thread, other threads:[~1999-06-09  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-27  0:00 Fixed Point Numbers Robert I. Eachus
1999-06-08  0:00 ` Robert A Duff
1999-06-09  0:00   ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
1999-05-27  0:00 Philip Bradley
1999-05-28  0:00 ` Robert Dewar

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