comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: Re: simple question on long_float/short_float
Date: Thu, 30 Sep 2010 17:29:46 -0700
Date: 2010-09-30T17:29:46-07:00	[thread overview]
Message-ID: <i83a23$mt$1@speranza.aioe.org> (raw)
In-Reply-To: 4ca4fff8$0$2437$4d3efbfe@news.sover.net

On 9/30/2010 2:21 PM, Peter C. Chapin wrote:
> On 2010-09-30 11:37, Jeffrey Carter wrote:
>
>> Are you saying that in Fortran you can only make floating-point
>> variables with one of two precisions?
>>
>> Is this for real?
>
> I don't know about old Fortran but in Fortran 90 and above you can
> specify the characteristics of your floating point type and ask the
> compiler to find an underlying type that works for you.
>
> Each compiler provides various "kinds" of floating point types.
> Depending on the underlying machine there might be several. These kinds
> are identified by compiler specific integer constants (kind 1, kind 2,
> etc). Of course referring to them that way isn't portable... my floating
> point type that is labeled as "kind 1" might be nothing like the
> floating point type you are labeling as "kind 1." To get around this you
> can use the intrinsic function SELECTED_REAL_KIND. It looks like this:
>
> INTEGER, PARAMETER :: my_floating_kind = SELECTED_REAL_KIND(6, 30)
>
> This asks the compiler to find a floating point type with at least 6
> digits of precision and a range that covers 10**30. The resulting kind
> (some number like 1, 2, 3, etc) is then given the name "my_floating_kind."
>
> I declare variables like this
>
> REAL(KIND = my_floating_kind) :: x, y, z
>
> The kind value is like a type parameter. Thus REAL(KIND = 1) means you
> want the first kind of floating point type, REAL(KIND = 2) means you
> want the second kind. In the declaration above "my_floating_kind" is
> used meaning that you want whatever kind is necessary to get the desired
> precision and range. Maybe that's kind 2 on my compiler and kind 17 on
> yours.
>
> Fortran compilers are required (I think) to provide a double precision
> type but internally that type is just a particular kind (maybe kind 2?).
> In modern Fortran you never have to say "double precision" the term
> exists for compatibility and convenience.
>
> We now return to our regularly scheduled discussion of Ada. :)
>
> Peter

Thanks Peter for this post, I did not know this about new Fortran.

I am finding that modern Fortran has become too complex, the language 
has so many new features now, I find even Ada to be simple compared to it :)

This trend to update computer languages every few years seems to result 
in a language first starting as simple, with the basic features, then it 
gets more and more complicated and bloated as more features are stuffed 
in it to make it more cool and modern. With time computer languages 
become too complex to understand by mere mortals, unless one has a PhD 
in computer science.

--Nasser




  reply	other threads:[~2010-10-01  0:29 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
2010-09-30 18:22       ` Nasser M. Abbasi
2010-09-30 21:21       ` Peter C. Chapin
2010-10-01  0:29         ` Nasser M. Abbasi [this message]
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