comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: simple question on long_float/short_float
Date: Thu, 30 Sep 2010 08:37:52 -0700
Date: 2010-09-30T08:37:52-07:00	[thread overview]
Message-ID: <i82bno$51k$1@tornado.tornevall.net> (raw)
In-Reply-To: <i81htk$nqf$1@speranza.aioe.org>

On 09/30/2010 01:31 AM, Nasser M. Abbasi wrote:
>
> Thanks. Are you saying that in Ada I can't make double precision
> variables and single precision variables? (as in Fortran?)
>
> Is this for real? :)

Are you saying that in Fortran you can only make floating-point variables with 
one of two precisions?

Is this for real?

In Ada, you can create floating-point types (and declare variables of those 
types) with any precision supported by the compiler, from 1 to System.Max_Digits 
decimal digits of precision.

> So, what is Ada's Float? 32 bit or 64 bits?

So in Fortran, you cannot make use of the 80-bit floating-point type supported 
by most PC FPUs?

In most languages (other than Ada), you have to use the numeric types provided 
by the language, and select the types that are the closest fit to the 
requirements of the problem. This is part of what is known as "translating the 
problem into the solution space", which makes the software harder to understand, 
since the reader has to understand both the problem and the translation chosen.

In Ada, one can declare numeric types to match the requirements of the problem. 
This is part of what is known as "modeling the problem in the software", which 
is intended to make the software easier to understand, since there is no 
translation from problem to solution space to understand.

Ada's Float is defined as "at least 6 decimal digits of precision". This 
definition is imprecise, presumably to discourage its use in favor of 
user-defined types. If the precision of a floating-point type is important to 
the problem, you won't use a predefined type, but will declare your own with the 
desired precision.

Thinking in terms of declaring numeric types based on the needs of the problem, 
rather than choosing from language-supplied types, is part of the Ada Mind Set(tm).

-- 
Jeff Carter
"I'm particularly glad that these lovely children were
here today to hear that speech. Not only was it authentic
frontier gibberish, it expressed a courage little seen
in this day and age."
Blazing Saddles
88



  parent reply	other threads:[~2010-09-30 15:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30  6:17 simple question on long_float/short_float Nasser M. Abbasi
2010-09-30  6:58 ` J-P. Rosen
2010-09-30  8:31   ` Nasser M. Abbasi
2010-09-30  8:45     ` Nasser M. Abbasi
2010-09-30  9:59       ` Mark Lorenzen
2010-09-30 13:30       ` Peter C. Chapin
2010-09-30  8:46     ` AdaMagica
2010-09-30 10:02     ` Georg Bauhaus
2010-09-30 15:37     ` Jeffrey Carter [this message]
2010-09-30 18:22       ` Nasser M. Abbasi
2010-09-30 21:21       ` Peter C. Chapin
2010-10-01  0:29         ` Nasser M. Abbasi
2010-10-01 11:13           ` Peter C. Chapin
2010-10-02 19:57         ` Simon Wright
2010-09-30 15:56     ` Adam Beneschan
2010-10-02  9:11 ` Nasser M. Abbasi
2010-10-02  9:48   ` Dmitry A. Kazakov
2010-10-02 20:09     ` Simon Wright
2010-10-02  9:56   ` Nasser M. Abbasi
2010-10-02 10:45   ` cjpsimon
2010-10-02 16:52   ` Jeffrey Carter
2010-10-02 20:01     ` Georg Bauhaus
replies disabled

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