comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: help Please
Date: 1999/01/27
Date: 1999-01-27T00:00:00+00:00	[thread overview]
Message-ID: <F689KH.MJI.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 36AEE12E.A97785D2@gecm.com

Steve Kerr (stephen.kerr@gecm.com) wrote:

: ...
: This does though raise an interesting point though (assuming that the same rules
: apply to the image attribute), how does Ada95 decide on the string
: representation of a floating point number for the image attribute ? i.e. how
: many decimal places to display and whether to display an exponent, particulaly
: where the float can be represented without an exponent (e.g. 0.1234). My guess
: is that this is compiler dependant, does anyone know different ?

Oh please, not compiler dependent! ;-).  

There is actually a surprisingly easy way to find this out, and 
that is to look in the Ada 95 Reference Manual.  (I suspect you 
will quickly be bombarded with repeats of this answer!)

The relevant paragraph is RM95 3.5(33):

  The image of a floating point value is a decimal real literal
  best approximating the value (rounded away from zero if halfway
  between) with a single leading character that is either a minus
  sign or a space, a single digit (that is nonzero unless the value
  is zero), a decimal point, S'Digits-1 (see 3.5.8) digits after
  the decimal point (but one if S'Digits is one), an upper case E, 
  the sign of the exponent (either + or -), and two or more digits
  (with leading zeros if necessary) representing the exponent.
  If S'Signed_Zeros is True, then the leading character is a minus
  sign for a negatively signed zero.

So the quicker answer is: Min(S'Digits-1, 1) digits after
the decimal point, and there will always be an exponent (ugly as
that may be ;-).

--
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  reply	other threads:[~1999-01-27  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <36ab9be5.2873369@news.ptd.net>
1999-01-24  0:00 ` help Please Matthew Heaney
1999-01-26  0:00   ` Simon Wright
1999-01-26  0:00   ` Steve Kerr
1999-01-26  0:00     ` David C. Hoos, Sr.
1999-01-27  0:00       ` Steve Kerr
1999-01-27  0:00         ` Tucker Taft [this message]
2000-05-22  0:00 help please saju sathyan
2000-05-22  0:00 ` Gautier
2000-05-23  0:00   ` saju sathyan
  -- strict thread matches above, loose matches on Subject: below --
2001-12-16 15:27 Pierrick
2001-12-16 18:27 ` Patrick Hohmeyer
2001-12-16 19:46 ` Steve Doiel
replies disabled

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