From: "Lawrence Velázquez" <vq@larryv.me>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: arithmetic anomaly
Date: Fri, 26 Mar 2021 13:09:19 -0400 [thread overview]
Message-ID: <254ED248-857D-460C-98B4-EFDF074CD6F8@larryv.me> (raw)
In-Reply-To: <691e63e8-aff6-cce6-d7b4-7bf6de10363a@eastlink.ca>
> On Mar 25, 2021, at 7:57 PM, Ray Andrews <rayandrews@eastlink.ca> 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@eastlink.ca> 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@eastlink.ca> 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@eastlink.ca> 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
next prev parent reply other threads:[~2021-03-26 17:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-25 15:52 Ray Andrews
2021-03-25 20:40 ` Lawrence Velázquez
2021-03-25 22:44 ` Ray Andrews
2021-03-25 22:54 ` Roman Perepelitsa
2021-03-25 23:57 ` Ray Andrews
2021-03-26 0:16 ` Oliver Kiddle
2021-03-26 0:37 ` Ray Andrews
2021-03-26 10:35 ` Roman Perepelitsa
2021-03-26 14:36 ` Ray Andrews
2021-03-26 14:49 ` Roman Perepelitsa
2021-03-26 15:35 ` Ray Andrews
2021-03-26 17:09 ` Lawrence Velázquez [this message]
2021-03-26 21:45 ` Ray Andrews
2021-03-26 21:59 ` Lawrence Velázquez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=254ED248-857D-460C-98B4-EFDF074CD6F8@larryv.me \
--to=vq@larryv.me \
--cc=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).