Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: arithmetic anomaly



On 2021-03-25 5:16 p.m., Oliver Kiddle wrote:
Ray Andrews wrote:
      printf "%.0f / %.0f \n" "$(( numerator ))" "$(( denominator ))"
Where you use %f, %d etc. the printf parameters are evaluated in math
context so there's no need to convert via ASCII decimal representation
with "$(( … ))". You can just do:

   printf "%.0f / %.0f \n" numerator denominator
Thanks.  Actually I just figured that out myself.
e of the shell rather than floats
but floats are what we have.
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.  Very unhygienic.






Messages sorted by: Reverse Date, Date, Thread, Author