Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: integer or float?
On Wed, Oct 1, 2025, at 10:42 PM, Ray Andrews wrote:
> My problem arose because of an internal string test not any display
> issue.
If you accessed the variable like $this, then it's more or less the
same issue.
> But why the dot? Of course zsh accepts it, but why is it output
> like that? Perhaps simply to flag the fact that it's been forced?
It's just part of how the shell represents floating point numbers;
it has nothing to do with FORCE_FLOAT specifically.
% unsetopt FORCE_FLOAT
% echo $((1.0))
1.
I don't know if there's a reason for not including a trailing "0".
> I'd have expected it to be left off unless there really is
> a decimal value.
That would lose information, so instead of this:
% x=$((1.0))
% typeset -p x
typeset x=1.
% print $((x / 2))
0.5
you would get this:
% x=$((1.0))
% typeset -p x
typeset x=1
% print $((x / 2))
0
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author