U23405@UICVM (Michael J. Steiner) (08/28/88)
I may go as far as to say that there should be two kinds of doubles, one with better precision and another with greater range. They could be called something like "acdouble" and "widouble" standing for "accurate double" and "wide double" respectively. I can't really choose between the two because whether a programmer would want to use an accurate double or a wide double would depend on what kind of application he is doing. Also, I recently heard of a "long double". Since double is defined as "long float", this would mean "long long float", which is confusing. As far as I know, C doesn't allow this. (It would be nice, though, to make a data type as long as you want by saying "long long long long ... <type>") Anyone hear about this? One last thing: Would an expression be evaluated more quickly if the RHS had variables of type short or type int? For example, which would be faster: int a, b, c; a = b * c - (int) 4; int a; short b, c; a = b * c - (short) 4; Michael Steiner P.S. Thanks for the help with Email: U23405@UICVM.BITNET sorting algorithms and "IF STATEMENT EFFICIENCY".
tada@athena.mit.edu (Michael Zehr) (09/07/88)
GRRR! lost the article reference ... sorry guys. > [comments about doubles deleted] >One last thing: Would an expression be evaluated more quickly if the RHS >had variables of type short or type int? > Michael Steiner This is extrememly machine dependant. Usually, if you declare something as type "int", the compiler will use the "natural" data type for the machine, which will usually be fastest. The only way to tell for sure would be to time it in various ways, on each machine you plan to use the code on. If you don't want to go to all that work, you're probably better of just using "int". -michael j zehr
gwyn@smoke.ARPA (Doug Gwyn ) (09/07/88)
In article <8809061831.AA29128@ucbvax.Berkeley.EDU> U23405@UICVM (Michael J. Steiner) writes: >I may go as far as to say that there should be two kinds of doubles, one >with better precision and another with greater range. The whole business of specifying detailed attributes of data types in a C-like language is something that should be totally reworked, rather than patched. >Also, I recently heard of a "long double". Since double is defined as >"long float", this would mean "long long float", which is confusing. "long float" is out; if you've been using this, you're advised to change it to "double" before you bump into a compiler that doesn't recognize "long float". "long double" is new with ANSI C. >One last thing: Would an expression be evaluated more quickly if the RHS >had variables of type short or type int? That depends on the implementation. "int" is usually the fastest data type, but not always. Just express the computation correctly and let the compiler worry about such micro-optimization.
henry@utzoo.uucp (Henry Spencer) (09/08/88)
In article <8809061831.AA29128@ucbvax.Berkeley.EDU> U23405@UICVM (Michael J. Steiner) writes: >I may go as far as to say that there should be two kinds of doubles, one >with better precision and another with greater range... X3J11 talked a bit about different kinds of floating-point, but I believe that there was insufficient experience for anyone to be confident of doing the right thing. Note that these two kinds of doubles would be identical on most real machines, since the hardware only offers one kind. >Also, I recently heard of a "long double". Since double is defined as >"long float", this would mean "long long float", which is confusing. "Long double" was the one thing X3J11 did do, to accomodate the large and growing number of machines that have an extra-large floating-point format. IEEE floating point requires an "extended" format, for example. (NB, there are a number of machines that use IEEE data formats without implementing the full IEEE standard.) Another example is that 64-bit supercomputers and that ilk will sometimes provide 128-bit floating point. This seemed an important thing to accommodate, and not too hard to handle. "long float" as a synonym for "double" is actually gone, since nobody ever used it. >As far as I know, C doesn't allow this. (It would be nice, though, to make >a data type as long as you want by saying "long long long long ... <type>") >Anyone hear about this? A nice idea in the abstract. Algol 68 did this, although I think it had a rule that the implementation could limit the number of underlying sizes and simply start ignoring "longs" at some point. There are people who have implemented "long long int" in C. >One last thing: Would an expression be evaluated more quickly if the RHS >had variables of type short or type int? ... With occasional exceptions, "int" is the type one uses if one is more concerned about speed than about space or number range. (A notable exception is 68000/010 implementations that make "int" 32 bits to reduce problems with poorly-written software; "short" may be faster there.) "Short" can be noticeably slower than "int". -- Intel CPUs are not defective, | Henry Spencer at U of Toronto Zoology they just act that way. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu
henry@utzoo.uucp (Henry Spencer) (09/14/88)
In article <1988Sep7.194946.4808@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >IEEE floating point requires an "extended" format, for example. (NB, there >are a number of machines that use IEEE data formats without implementing >the full IEEE standard.) ... Turns out I missed a bit of weasel-wording in the standard that permits one to implement just single precision plus a corresponding extended format, and double precision meets (I think) the constraints on extended single, so it is technically legitimate to have just single and double. Barf. -- NASA is into artificial | Henry Spencer at U of Toronto Zoology stupidity. - Jerry Pournelle | uunet!attcan!utzoo!henry henry@zoo.toronto.edu
wes@obie.UUCP (Barnacle Wes) (09/16/88)
In article <8809061831.AA29128@ucbvax.Berkeley.EDU>, U23405@UICVM (Michael J. Steiner) writes: > I may go as far as to say that there should be two kinds of doubles, one > with better precision and another with greater range. They could be called > something like "acdouble" and "widouble" standing for "accurate double" > and "wide double" respectively. Actually, there ARE two kinds of doubles: D_floating and G_floating. D_floating is a 64-bit format with 1 sign bit, 8 bit exponent excess 128, and 56-bit normalized fraction. The range of D_floating is 0.29e-38 to 1.7e38, with approximately 16 decimal digits of precision. G_floating is a 64-bit format with 1 sign bit, 11 bit exponent excess 1024 (!), and 53-bit normalized fraction. The range of G_floating is 0.56e-308 to 0.9e308, with approximately 15 decimal digit precision. These are, of course, VAX floating-point formats. > I can't really choose between the two > because whether a programmer would want to use an accurate double or a wide > double would depend on what kind of application he is doing. With most VAX compilers, you don't have to choose one or the other, you can get both. If your system supports G_floating, that is. The MicroVAX doesn't, I think it just uses D_floating if you ask for G_floating. > Also, I recently heard of a "long double". Since double is defined as > "long float", this would mean "long long float", which is confusing. Yup. This is called H_floating. Surpised? I thought not. H_floating is a 128-bit format with 1 sign bit, 15 bit exponent excess 16384 (!!!), and a 113-bit normalized fraction. The range of H_floating is 0.84e-4932 to 0.59e4932, and the precision is typically 33 decimal digits!!! > As far as I know, C doesn't allow this. (It would be nice, though, to make > a data type as long as you want by saying "long long long long ... <type>") > Anyone hear about this? I think VAX C has some way of support the "other" floating point standards, but of course, that's a somewhat weird compiler. When in Rome, etc.... -- {hpda, uwmcsd1}!sp7040!obie!wes "How do you make the boat go when there's no wind?" -- Me --