Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

integer or float?



Accidentally left option forcefloat active and a function of mine stopped working.  It boils down to this:

4 /aWorking/Zsh/Source/Wk 4 % cat test
#!/usr/bin/zsh

integer MAX_INDEX=2
local idx=        
for ((idx=$MAX_INDEX; idx>0; idx--)); do
    echo $idx            
done

4 /aWorking/Zsh/Source/Wk 4 % unsetopt forcefloat; .test
2
1

4 /aWorking/Zsh/Source/Wk 4 % setopt forcefloat; . test
2.
1.

... anyway I've figured out that 'integer idx' cures the problem, so it seems that forcefloat affects a scalar but not an integer which seems backwards.  Also, '1.' is mathematically distasteful is it not?  The trailing dot is rude, one might expect '1.0' or just leave the dot off when there is no actual float value.  Thoughts?




Messages sorted by: Reverse Date, Date, Thread, Author