From: Simon Wright on 10 Jun 2010 16:12 "Nasser M. Abbasi" <nma(a)12000.org> writes: > On 6/10/2010 12:23 AM, Stephen Leake wrote: > >> >>> -- gnatmake dft.adb >>> -- >>> -- ./dft.exe >>> -- ( 6.00000E+00, 0.00000E+00) >>> -- (-1.50000E+00, 8.66026E-01) >>> -- (-1.50000E+00,-8.66025E-01) >>> -- $ >>> >>> ======= FORTRAN code =========== >>> ! dtf.f90, compiled with GCC 4.3.4 >>> ! under CYGWIN 1.7.5 >>> ! gfortran -Wall dft.f90 >>> ! ./a.exe >>> ! ( 6.0000000 , 0.0000000 ) >>> ! ( -1.4999999 , 0.86602557 ) >>> ! ( -1.5000005 ,-0.86602497 ) >>> ! >> > >> It would be good to explain the small differences here; something about >> how the floating point options are set, I suspect. >> > > Yes, I noticed that too. Need to look more into. It could be just a > formating thing. I just used Print*, in Fortran becuase at the time > was too lazy to lookin up the other formating functions in Fortran. In > Ada, I used the predefined Put on Complex of float types. I tried with put(X(k), Aft => 8, Exp => 0); new_line; (to match the number of digits output by the Fortran) and got ( 6.00000000, 0.00000000) (-1.49999988, 0.86602557) (-1.50000024,-0.86602497) so I think it's just a formatting thing (though that -1.50000024 looks a little off; but Float is digits 6 on this hardware - Macbook Pro, so those last 3 digits are spurious).
From: Yannick Duchêne (Hibou57) on 10 Jun 2010 17:15 Le Thu, 10 Jun 2010 15:27:38 +0200, J-P. Rosen <rosen(a)adalog.fr> a écrit: > For output, rounding is specified in the standard. And BTW, the standard > does not specify IEEE (fortunately, it did not make the same mistake as > Java!). Which mistake ? (not to disagree, just to understand) -- There is even better than a pragma Assert: a SPARK --# check. --# check C and WhoKnowWhat and YouKnowWho; --# assert Ada; -- i.e. forget about previous premises which leads to conclusion -- and start with new conclusion as premise.
From: Randy Brukardt on 10 Jun 2010 18:32 "Jeffrey R. Carter" <spam.jrcarter.not(a)spam.acm.org> wrote in message news:hur95a$3oh$1(a)tornado.tornevall.net... > Colin Paul Gloster wrote: >> >> Though there should be no difference, in reality compilers produce >> less slow machine code when looping down to zero instead of up from >> zero. > > The root of all evil. Goody, we're playing Jeopardy! I assume that was "Programming" for 200. :-) Q: What is premature optimization?? Randy.
From: Dmitry A. Kazakov on 11 Jun 2010 03:22 On Thu, 10 Jun 2010 23:15:37 +0200, Yannick Duch�ne (Hibou57) wrote: > Le Thu, 10 Jun 2010 15:27:38 +0200, J-P. Rosen <rosen(a)adalog.fr> a �crit: >> For output, rounding is specified in the standard. And BTW, the standard >> does not specify IEEE (fortunately, it did not make the same mistake as >> Java!). > Which mistake ? (not to disagree, just to understand) Making language hardware-dependent. Plus, IEEE is not very good for computational and engineering tasks. In particular, when programming in Ada, you should better kill IEEE semantics regarding overflows for built-in types. E.g. type Real is new Float range Float'Range; -- Now it works as it has to -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: J-P. Rosen on 11 Jun 2010 04:48
Yannick Duch�ne (Hibou57) a �crit : > Le Thu, 10 Jun 2010 15:27:38 +0200, J-P. Rosen <rosen(a)adalog.fr> a �crit: >> For output, rounding is specified in the standard. And BTW, the standard >> does not specify IEEE (fortunately, it did not make the same mistake as >> Java!). > Which mistake ? (not to disagree, just to understand) > What can you do if you have a non-IEEE machine (number crunchers like Silicon-Graphics machine are not IEEE)? Either emulate IEEE in software, but you are wasting speed and the money you invested in such machines, or implement Java with the native arithmetic, ignoring the standard => total failure of the standard. There is an interesting paper on the internet about why Java failed on numerics. Sorry, I don't have the exact reference at hand, but it should be easy to find. -- --------------------------------------------------------- J-P. Rosen (rosen(a)adalog.fr) Visit Adalog's web site at http://www.adalog.fr |