Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: print and floating point output
- X-seq: zsh-workers 19915
- From: Matthias Kopfermann <matthi@xxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: print and floating point output
- Date: Tue, 11 May 2004 15:08:57 +0200
- Cc: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
On Tue, May 11, 2004 at 01:01:06PM +0100, Peter Stephenson wrote:
> Well, the alternative is silently censoring decimal places, many of
> which may be valid. If you want something smart to guess how many
> places are valid, you need to write it.
So you think that ruby, perl and python censor output?
I think that's just useful and uses the principle of least
surprise.
> typeset -E 8 var
>
> then
>
> (( var = 2.8 * 16.0 ))
> print $var
>
> for a given number of decimal places. Or use printf, which does it's
> own conversion:
I know about printf and typeset already. I just thought that
perl, ruby and python have good points in their decision,
too. :)
And what's the way of using typeset with something like
print $((2.8*16.0)) ?
plus, bc does it that way, too.
and i don't think that bc does censor my output at all.
Well, to a point there always is censoring with floating
point, ack!
>
> % printf "%f\n" $((2.8*16.0))
> 44.800000
Why is that no censoring then?
>
> If you are doing serious floating point work, unfortunately you need to
> understand something about rounding errors, which are a tricky and
> ever-present feature.
I learned that here.
Matthias
Messages sorted by:
Reverse Date,
Date,
Thread,
Author