[prev in list] [next in list] [prev in thread] [next in thread]
List: hugs-bugs
Subject: Re: Perhaps a Very Small Bug
From: Ross Paterson <ross () soi ! city ! ac ! uk>
Date: 2001-06-28 15:18:05
Message-ID: 20010628161805.A19487 () soi ! city ! ac ! uk
[Download RAW message or body]
On Thu, Jun 28, 2001 at 02:57:48PM +0100, Iain McNaughton wrote:
> I was using WinHugs as a calculator. From the main command prompt in
> WinHugs, I typed the following:
>
> 102.0*201.0 + 103.0*202.0 + 102.0*201.0 +102.0*202.0 + 102.5*200.5
>
> I then hit 'return', and was presented with the answer:
>
> 102965.0
Indeed, you get that answer if you type 102965.25, which is somewhat
confusing. Hugs is converting this to a string with sprintf %g,
which yields "102965". It can't print that out because it looks
like an Int, so it appends ".0". This only happens if there are
6 digits before the decimal point. (It also does changes 4e+5 to
4.0e+5, but that can't go wrong like this.)
All this is in floatToString in machdep.c. A hack-around is to change
the line
if (buffer1[i]!='.') {
to
if (buffer1[i]=='\0') {
sprintf(buffer1,"%.1f",fl);
i = j = 0;
} else if (buffer1[i]!='.') {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic