From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8c0fcfc0a87e61fc X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: simple question on long_float/short_float Date: Thu, 30 Sep 2010 17:29:46 -0700 Organization: Aioe.org NNTP Server Message-ID: References: <4ca4fff8$0$2437$4d3efbfe@news.sover.net> Reply-To: nma@12000.org NNTP-Posting-Host: tUYQ4Ty9mMw9Pdc8TJRFQA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.12) Gecko/20100914 Thunderbird/3.0.8 Xref: g2news1.google.com comp.lang.ada:14341 Date: 2010-09-30T17:29:46-07:00 List-Id: 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