* Does Ada 95 conform to the IEEE 754 floating point standard? @ 1997-12-03 0:00 Samir N. Muhammad 1997-12-03 0:00 ` Robert Dewar 0 siblings, 1 reply; 7+ messages in thread From: Samir N. Muhammad @ 1997-12-03 0:00 UTC (permalink / raw) Hi Everybody I was wondering whether Ada 95 conform to the IEEE 754 floating point standard. Pointers to URLs, papers, etc. are highly appreciated. Thanks in advance Samir Muhammad ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does Ada 95 conform to the IEEE 754 floating point standard? 1997-12-03 0:00 Does Ada 95 conform to the IEEE 754 floating point standard? Samir N. Muhammad @ 1997-12-03 0:00 ` Robert Dewar 0 siblings, 0 replies; 7+ messages in thread From: Robert Dewar @ 1997-12-03 0:00 UTC (permalink / raw) Samir asks << I was wondering whether Ada 95 conform to the IEEE 754 floating point standard. Pointers to URLs, papers, etc. are highly appreciated. >> Unlike the Language Independent Arithmetic standard, IEEE is NOT a standard about what programming languages should do. Rather it is a standard that specifies a set of functions that must be available. Obviously Ada itself does not mandate IEEE, because then it could not be implemented with reasonable efficiency on non-IEEE machines, or more accurately on machines not providing full IEEE facilities in hardware. Java *does* mandate such support, and a consequence is that it is impossible to implement Java with reasonable efficiency on machines (like the SGI MIPS R10000, or the Alpha) which do not provide full IEEE support in hardware. In practice everyone just ignores this requirement in java and uses native arithmetic, assuming it is near enough. Ada 95 is carefully designed to be compatible with the IEEE 754 and 854 standards, but to actually provide a full IEEE environment requires, in addition to operation on a machine fully supporting IEEE semantics, a package of appropriate interface definitions. A student of mine, Sam Figueroa, is working on a thesis that among other aspects, will provide a full implementation of these interfaces, and we expect to be providing this with GNAT sometime in the future. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Does Ada 95 conform to the IEEE 754 floating point standard? @ 1998-02-04 0:00 Samir N. Muhammad 1998-02-04 0:00 ` Joe Gwinn 1998-02-04 0:00 ` Robert Dewar 0 siblings, 2 replies; 7+ messages in thread From: Samir N. Muhammad @ 1998-02-04 0:00 UTC (permalink / raw) Hello Everyone Does anyone know whether the Ada 95 standard say anything about the conformance of Ada 95 to the IEEE 754 standard (i.e. floating point standard). I checked some sections of the standard and could not find such information. Any pointers (especially to the standard) are highly appreciated. Thanks in advance Samir Muhammad ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does Ada 95 conform to the IEEE 754 floating point standard? 1998-02-04 0:00 Samir N. Muhammad @ 1998-02-04 0:00 ` Joe Gwinn 1998-02-04 0:00 ` Matthew Heaney 1998-02-04 0:00 ` Robert Dewar 1 sibling, 1 reply; 7+ messages in thread From: Joe Gwinn @ 1998-02-04 0:00 UTC (permalink / raw) Ada95 allows one to use the arithmetic built into the processor one's program runs on. If that hardware complies to IEEE 754, so much the better, but Ada has nothing to do with it, and nor should it. IEEE 754 is a hardware representation, handled by the computer. To access these 32-bit single-real numbers, one must declare variables as type "float" in ANSI C or type "FLOAT" in Ada [LRM section 3.5.7]. To access 64-bit double-real numbers, one must declare variables as type "double" in C or type "LONG_FLOAT" in Ada [Ada LRM section 3.5.7]. In Fortran-77 [ANSI X3.9-1978, Section 4], these types are called "real" and "double precision" respectively. Note that it isn't enough to say only that a variable is a single (32-bit) float or a double (64-bit) float. There must be fifty different floating-point formats in existence, especially in legacy systems. IEEE 754 is steadily displacing all other formats, but it will be some time before all other formats have totally disappeared. Joe Gwinn In article <6b8fdn$qrh17@beaker.nit.gwu.edu>, sam818@seas.gwu.edu (Samir N. Muhammad) wrote: > Hello Everyone > > Does anyone know whether the Ada 95 standard say anything about the conformance > of Ada 95 to the IEEE 754 standard (i.e. floating point standard). I checked > some sections of the standard and could not find such information. Any pointers > (especially to the standard) are highly appreciated. > > > Thanks in advance > Samir Muhammad ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does Ada 95 conform to the IEEE 754 floating point standard? 1998-02-04 0:00 ` Joe Gwinn @ 1998-02-04 0:00 ` Matthew Heaney 1998-02-05 0:00 ` Robert Dewar 0 siblings, 1 reply; 7+ messages in thread From: Matthew Heaney @ 1998-02-04 0:00 UTC (permalink / raw) In article <gwinn-0402981333140001@dh5055139.res.ray.com>, gwinn@res.ray.com (Joe Gwinn) wrote: >IEEE 754 is a hardware representation, handled by the computer. To access >these 32-bit single-real numbers, one must declare variables as type >"float" in ANSI C or type "FLOAT" in Ada [LRM section 3.5.7]. To access >64-bit double-real numbers, one must declare variables as type "double" in >C or type "LONG_FLOAT" in Ada [Ada LRM section 3.5.7]. It might be better to use the types Interfaces.IEEE_Float_32 and Interfaces.IEEE_Float_64, because you have no guarantee that types Float and Long_Float are any different. If you want the IEEE format, then state that explicitly, by using the types in package Interfaces. See AARM B.2 (10.a). ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does Ada 95 conform to the IEEE 754 floating point standard? 1998-02-04 0:00 ` Matthew Heaney @ 1998-02-05 0:00 ` Robert Dewar 0 siblings, 0 replies; 7+ messages in thread From: Robert Dewar @ 1998-02-05 0:00 UTC (permalink / raw) Joe said <<In article <gwinn-0402981333140001@dh5055139.res.ray.com>, gwinn@res.ray.com (Joe Gwinn) wrote: >IEEE 754 is a hardware representation, handled by the computer. To access >these 32-bit single-real numbers, one must declare variables as type >"float" in ANSI C or type "FLOAT" in Ada [LRM section 3.5.7]. To access >64-bit double-real numbers, one must declare variables as type "double" in >C or type "LONG_FLOAT" in Ada [Ada LRM section 3.5.7]. >> Earlier, Joe and I had a long discussion about the importance of knowing the language as opposed to the implementation, among other things. Joe dismissed this as requiring "ada experts" ... But the above is a good example of sloppiness that comes from not making this distinction, and this kind of error can cause huge problems in porting code later on. There is absolutely NO indication, let alone a guarantee, that on an IEEE machine, float will map to IEEE short and LONG_Float to IEEE long (the same is true of ANSI C). Yes, it is a likely choice, but there have been Ada compilers, where Float was 64-bits and you had to use Short_Float to get 32 bits. In Ada 83, the best shot would be something like type IEEE_Short is digits 6; type IEEE_Long is digits 15; there is no still no requirement in Ada 83 that you will get what you want. You could however confirm that the right choices have been made using: for IEEE_Short'Size use 32; for IEEE_Long'Size use 64; but that still would not be adequate on an Alpha, where there is nothing to stop the compiler from choosing Vax Float formats in both cases (indeed DEC Ada 83 does choose Vax Float by default). In Ada 95, the problem is entirely solved by using the appropriate types in Interfaces. In any case, Joe's advice is badly flawed. To use the predefined types Float and Long_Float is really asking for trouble. Even in Ada 83, where there is no 100% guaranteed way of ensuring you get the IEEE types, the proper approach is to define types in the above manner and use them. This way, you only have to make changes at one small point in your program when you port (e.g. in DEC Ada 83, use the pragma Float_Representation). Note that this advice also applies to C. In C, there is even less control to help ensure getting the right types, but by using typedefs, you can isolate the degree of change. This kind of abstraction is absolutely essential in programming if you want to write portable code. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does Ada 95 conform to the IEEE 754 floating point standard? 1998-02-04 0:00 Samir N. Muhammad 1998-02-04 0:00 ` Joe Gwinn @ 1998-02-04 0:00 ` Robert Dewar 1 sibling, 0 replies; 7+ messages in thread From: Robert Dewar @ 1998-02-04 0:00 UTC (permalink / raw) Samir asks <<Does anyone know whether the Ada 95 standard say anything about the conformance of Ada 95 to the IEEE 754 standard (i.e. floating point standard). I checked some sections of the standard and could not find such information. Any pointers (especially to the standard) are highly appreciated. >> The IEEE 754 standard is a combined hardware/software standard that requires certain facilities to be available at the programming language level. Most certainly the Ada 95 RM does not require IEEE conformance, since it is designed to run on machines which do not implement reasonable hardware for this purpose. The intention is that Ada 95 compilers map to the underlying floating-point hardware, whether or not it is IEEE compliant or consistent. Even on an IEEE machine, Ada 95 will implement only a subset of the 754 (or 854 remember the update) standard. However, a big difference in Ada 95, compared to Ada 83, is that Ada 95 is "IEEE-ready", in that it is not inconsistent with the standard, whereas with Ada 83 there were some definite glitches in this respect. What you need in Ada 95 is a package that provides required features, plus some additional support from the compiler. My PhD thesis student Sam Figueroa is working on a thesis that examines the issues of IEEE compliance in high level languages, and one of the work products is a complete binding for IEEE that we intend to fully implement in GNAT. Robert Dewar ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1998-02-05 0:00 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-12-03 0:00 Does Ada 95 conform to the IEEE 754 floating point standard? Samir N. Muhammad 1997-12-03 0:00 ` Robert Dewar -- strict thread matches above, loose matches on Subject: below -- 1998-02-04 0:00 Samir N. Muhammad 1998-02-04 0:00 ` Joe Gwinn 1998-02-04 0:00 ` Matthew Heaney 1998-02-05 0:00 ` Robert Dewar 1998-02-04 0:00 ` Robert Dewar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox