Re: Looping using iterators with fractional values

beliavsky_at_aol.com
Date: 01/01/05


Date: 1 Jan 2005 14:46:17 -0800

Mike Meyer wrote:

>Or - and much safer when dealing with floating point numbers - iterate
>over integers and generate your float values:

>for j in range(1, 9):
> i = j * .25
> print "%9.2f" % i

I agree with this suggestion. As an historical aside, Fortran had loops
with floating point variables for decades, but in 1995, the first
standard in a while to REMOVE features, this was one of the few things
deleted. The Fortran standards committee is very conservative about
creating backwards incompatibilities, but they must have thought loops
with floating point variables are so error-prone -- and alternatives
with integer counters are so easy to write -- that they put their foot
down. I know the OP is asking about Python, but the principle is the
same.



Relevant Pages

  • Re: CPU for Compaq Fortran V 6.4
    ... do loops and if statements. ... compilers generated code to do it from without any help. ... It used the same registers as the ... floating point, so it wasn't so useful for numerical number ...
    (comp.lang.fortran)
  • Re: Why float is called as float, not real?
    ... My guess is that "floating point" was used to distinguish the data representation from "fixed point." ... The oldest computer languages I've used, FORTRAN and ALGOL, both use "real," but as Glen noted, that wasn't the case with primeval FORTRAN. ... As Gib noted, even with a countably infinite number of bits, computers couldn't come close to representing all of the reals. ...
    (comp.lang.fortran)
  • Re: help reading fortran generated binary data...
    ... >> Helmut Giese ... That would probably have been Arjen, Tcl's FORTRAN guru:) but he ... floating point values as raw binary data, so I am only guessing here. ... read them back in using programs compiled with the same compiler - ...
    (comp.lang.tcl)
  • Poor performance of implied-DO loop with Intel Fortran
    ... Intel fortran compliers. ... I get very poor performance when using implied-DO loops to initialise ... I wasn't able to time v8.0 of the Intel compiler because it segfaulted ... unless I hid them in a subroutine. ...
    (comp.lang.fortran)
  • Re: Question on ProDOS SmartPort drive remapping
    ... that many believe that Fortran 66 requires it. ... If if was natural to use BXLE (Branch on indeX Less ... has an interesting debug feature that H doesn't have, ... real bear to interpret at runtime, with its implied DO loops, etc. ...
    (comp.sys.apple2)