[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Forum] Fwd: Re: UNKNOWN SigFigs-1.01 MacOS_CFM68K 7.6



Chris:
	Sullivan and I have been testing/exploring the behaviour of his
SigFigs module under MacOS. I'm fairly new, have there been reports of
problems with the printf routine as outlined below?
 printf("%.0f",0.99);
0

>Received: from cise.ufl.edu (rays.cise.ufl.edu [128.227.224.5]) by
>eagle.freespace.net (8.8.8/8.6.9) with ESMTP id IAA02154 for
><ljmoore@freespace.net>; Tue, 20 Apr 1999 08:21:49 -0400 (EDT)
>Received: from cise.ufl.edu (IDENT:2624@cave.cise.ufl.edu [128.227.224.31])
>	by cise.ufl.edu (8.9.1a/8.9.0/jfh) with ESMTP id IAA21559;
>	Tue, 20 Apr 1999 08:17:33 -0400 (EDT)
>X-Mailer: exmh version 2.0.2 2/24/98
>To: Larry Moore <ljmoore@freespace.net>
>cc: sbeck@cise.ufl.edu
>Subject: Re: UNKNOWN SigFigs-1.01 MacOS_CFM68K 7.6
>Mime-Version: 1.0
>Date: Tue, 20 Apr 1999 08:17:31 -0400
>From: "Sullivan N. Beck" <sbeck@cise.ufl.edu>
>
>> At 17:23 -0400 19/04/1999, Sullivan N. Beck wrote:
>> >By the way, I expect that the output you're going to see in the second test
>> >will be:
>> >
>> >FSF 00  0
>> >FSF 01  %.0f
>> >FSF 02  0.99
>> >FSF 03  0
>> >
>> >If that's true, then the problem is that the printf library routine is
>> >formatting:
>> >
>> >   printf("%.0f",0.99)  => 0
>> >
>> >which is incorrect and is a bug in the printf library routine.  Let me
>>know.
>> >
>> I don't have a c compiler on this Mac. The only c book I have is the AT&T
>> 3B2 ProgRefMan.
>> It doesn't say whether the result of "%.0f" is truncated or rounded. Do you
>> have a cite either way?
>> got:
>> # FSF 00  0
>> # FSF 01  %.0f
>> # FSF 02  0.99
>> # FSF 03  0
>> 0.
>>
>> Sigh.
>
>Here's from the Solaris printf(3s) man page which, while I wouldn't give it
>exactly the same weight as an official description of the C library routines
>(which I couldn't find anywhere), it's based on it, so I think it should
>be reasonable accurate:
>
>     f              The double args is converted to decimal nota-
>                    tion  in  the  style  [-]ddd.ddd,  where  the
>                    number  of  digits  after  the  decimal-point
>                    character (see setlocale(3C)) is equal to the
>                    precision specification.  If the precision is
>                    omitted  from  arg, six digits are output; if
>                    the  precision is explicitly zero and  the  #
>                    flag is not specified, no decimal-point char-
>                    acter appears.  If a decimal-point  character
>                    appears,  at least 1 digit appears before it.
>                    The  value  is  rounded  to  the  appropriate
>                                    ^^^^^^^
>                    number of digits.
>
>Given this, I'd have to call the behavior you're seeing a bug in your
>printf library call.
>
>You might want to report this but to whomever provides the libraries (but
>I'd definitely want to check it out in C if at all possible first).
>
>Sorry I can't be of more help at this point.
>
>
>------------------------------------------------------------------------------
>Sullivan Beck                      http://www.cise.ufl.edu/~sbeck/
> sbeck@cise.ufl.edu  | This space reserved for some saying demonstrating great
> PH : (352) 392-1057 | wisdom, wit, or insight.  I'll fill it in just as soon
> Fax: (352) 392-1220 | as I have any of the above.
>------------------------------------------------------------------------------
>

-
The world is one country and mankind, its citizens.

Larry Moore and Shirley Allan
Union Street West
Fergus ON Canada



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org