Re: Sensibly printed floats?
From: Eric Sosman (esosman_at_acm-dot-org.invalid)
Date: 01/08/05
- Next message: http://vmdd.tech.mylinuxisp.com/catalog/: "VMDD Tech announces the availability of CS101 - Decimal/Hex/Binary calculator"
- Previous message: Adam Warner: "Sensibly printed floats?"
- In reply to: Adam Warner: "Sensibly printed floats?"
- Next in thread: Malcolm: "Re: Sensibly printed floats?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 08 Jan 2005 08:53:27 -0500
Adam Warner wrote:
> Hi all,
>
> I'm used to ANSI Common Lisp implementations sanely printing single and
> double floats. By sane I mean the printed decimal representation mimics
> the underlying binary precision of the float. For example:
>
> [1]> (coerce 2/3 'single-float)
> 0.6666667
> [2]> (coerce 2/300 'single-float)
> 0.006666667
> [3]> (coerce 2/3 'double-float)
> 0.6666666666666666d0
> [4]> (coerce 2/300 'double-float)
> 0.006666666666666667d0
> [5]> (coerce 2/30000 'double-float)
> 6.666666666666667d-5
>
> Does C99 provide a method to print floats this way (apart from `f', `d'
> etc. exponential markers)?
I'm not entirely sure I understand what you mean by
"this way," but perhaps the "%g" conversion specifier is
what you're looking for.
-- Eric.Sosman@sun.com
- Next message: http://vmdd.tech.mylinuxisp.com/catalog/: "VMDD Tech announces the availability of CS101 - Decimal/Hex/Binary calculator"
- Previous message: Adam Warner: "Sensibly printed floats?"
- In reply to: Adam Warner: "Sensibly printed floats?"
- Next in thread: Malcolm: "Re: Sensibly printed floats?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|