Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic anomaly
> On Mar 25, 2021, at 7:57 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> That's for sure. I'd rather the result was truncated. Why show
> garbage?
> On Mar 25, 2021, at 8:37 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> But why do we let them spew out garbage? Just now I experimented
> with " %d " as the output specifier and it very politely goes
> obviously wrong at level 16 so you know it's reached the end of its
> rope, but the floats just keep on floating way into nonsense.
> On Mar 26, 2021, at 10:36 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> I'm asking why the 'Level: 100' result isn't just aborted after 15
> digits given that all the rest is garbage?
> On Mar 26, 2021, at 11:35 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> surely in my case it's simply a plain fact that no decimal past 15
> can be accurate ever?
zsh already knows how to indicate an appropriate degree of precision.
You are FORCING it to spew garbage.
% cat /tmp/demo.zsh; echo
python3.9 <<\EOF
print(f"{'Python:':<11} {22**22}")
EOF
printf '%-10s %s\n' 'zsh (%s):' $(( 22.0**22 ))
printf '%s %.0f\n' 'zsh (%.0f):' '22.0**22'
% zsh /tmp/demo.zsh
Python: 341427877364219557396646723584
zsh (%s): 3.4142787736421956e+29
zsh (%.0f): 341427877364219559508793360384
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author