Re: integer or float?
Lawrence Velázquez <[email protected]> Wed, 01 Oct 2025 20:22:55 -0400
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Oct 1, 2025, at 3:57 PM, Ray Andrews wrote: > ... 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. It does affect integer variables, but it doesn't affect the values that get stored in such variables. Here's what I mean: % setopt FORCE_FLOAT % unset -v i j % i= % echo $((i = 1)) 1. % typeset -p i typeset i=1. % integer j % echo $((j = 1)) 1 % echo $((j)) 1. % typeset -p j typeset -i j=1 > Also, '1.' is mathematically distasteful is it not? The > trailing dot is rude It's valid in zsh arithmetic, so it doesn't matter whether it's "distasteful" or "rude". You should be formatting the output with printf or print -f anyway, if you care about its appearance. % unset -v k % k=1. % printf '%d\n' $k 1 -- vq