This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
However, the original thread was not about rounding "0.2500000" It was about rounding results which could be 0.2499997 with one set of options, or 0.2500003 with another set of options. OP did not divulge (may not have remembered?) which options were used, whether it was 32- or 64-bit compilation, and other relevant issues. If OP wanted to round numbers to nearest multiple of 1/20, prior to rounding to 0.2 or 0.3, that could be done, but there was nothing of that nature in the posted code. OP is complaining about porting difficulties. Those are sure to arise with the evident lack of attention exhibited here.Ad hoc I don't see why the others print "0.2" for "0.2500000"; following
normal school maths one would round to 0.3.
Tie rounds to even rule (used in all modern CPUs for rounding; if someone has a good explanation, I'd be interested, the most plausible I have heard is some 'entropic' argument: 2 is better than 1.9999!-).
If I remember correctly my reading of the F2003 draft there are the usual NEAREST (tie to even), ZERO, UP, DOWN rounding modes for I/O plus another one (don't remember the name) which does the 'correct for business' rounding (tie to up).
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |