Re: integer or float?
Ray Andrews <[email protected]> Thu, 2 Oct 2025 07:11:39 -0700
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <[email protected]> |
On 2025-10-02 06:16, Mark J. Reed wrote: > So that period is conveying type information. A trailing 0 would > also,work though it suggests a level of precision that may not be > appropriate. But printing the float value 1. as "1" would destroy ... of course! I'm not wanting the dot gone, I'm wanting a zero added. BTW, to split hairs, there is, very technically, an issue there with indication of precision. The zero is conventional to 'guard' the dot from being overlooked, but it could be taken as indicating precision to the first decimal. Thus we have scientific notation where we need to be very clear about it. IMHO the value of a decimal number is what it is, there's no suggestion of precision being relevant. 1.1 is exactly 1.1, the value is not measured, it is stated. % echo $((.5)) 0.5 ... zsh very politely fixes sloppy input. % echo $((1.0)) 1. ... zsh very rudely breaks correct input. That can't be right. If I go to the trouble to add the zero, why remove it? Anyway it's hardly a big deal, I don't want to flog this to death. % var=1.1 % echo $((var)) 1.1000000000000001 # I myself would prefer '1.1' % var=1.0 % echo $((var)) 1. # I'd prefer '1.0' % echo $((1.001)) 1.0009999999999999 # '1.001' please Nevermind, it's not worth anyone's trouble.