Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: integer or float?
On Thu, Oct 2, 2025 at 10:35 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Yeah, fair enough, I concede the point. we see the internal
> representation there, I suppose it could be a design decision
It should be noted that you're seeing an effect of FORCE_FLOAT.
A scalar (string) forced to floating point by math
% setopt force_float
% i=1
% print $i
1
% ((i=1))
% print $i
1.
Vs. a parameter created (not merely assigned) by a math expression
% setopt force_float
% ((j=1))
% print $j
1.0000000000
(ten decimal places is the default if not declared)
Vs. a parameter declared floating point (force_float irrelevant!)
% typeset -F f
% ((f=1))
% print $f
1.0000000000
% typeset -F 2 f
% print $f
1.00
Vs. a parameter declared integer (force_float irrelevant)
% integer k
% ((k=1.3))
% print $k
1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author