From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: delta?
Date: 1999/02/27
Date: 1999-02-27T00:00:00+00:00 [thread overview]
Message-ID: <m3btif32zy.fsf@mheaney.ni.net> (raw)
In-Reply-To: 7b9bl7$ki5$1@eng-ser1.erg.cuhk.edu.hk
ycli6@se.cuhk.edu.hk (yukchi) writes:
> what is the meaning of delta and digits in the following sentence?
> type Money is delta 0.01 digits 15;
This is the declaration of a decimal fixed point type. It means values
of Money as small as 1 cent are exactly representable. Compare this to
a floating point type, which can only approximate the value of 1 cent.
You could do something like that using just plain fixed point types,
like this:
Money_Delta : constant := 0.01;
Money_First : constant := Integer'Pos (Integer'First) * Money_Delta;
Money_Last : constant := Integer'Pos (Integer'Last) * Money_Delta;
type Money is delta Money_Delta range Money_First .. Money_Last;
for Money'Small use Money_Delta;
which gives you the range you can fit in an object with the same
precision as Integer.
BTW: The attribute T'Pos is handy here, because it allows you to convert
a static subtype to a univeral type, which you can then use in a
universal expression.
next prev parent reply other threads:[~1999-02-27 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-27 0:00 delta? yukchi
1999-02-27 0:00 ` delta? David C. Hoos, Sr.
1999-02-27 0:00 ` Matthew Heaney [this message]
1999-02-28 0:00 ` delta? Tom Moran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox