🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2133

BC++ 2.0 sprintf "%f" bug in Windows

#2133
From: Eric Bergman-Terrell
Date: Wed, 17 Apr 1991 05:11
33 lines
1746 bytes
Folks:

There is a bug in BC++ 2.0's sprintf routine which shows up in Windows
applications - certain floating point numbers don't get ascii-fied 
correctly.

For example, the following doesn't work:

sprintf(str, "%f", (float) 24 / 27);

After the above call, str has a value of "1.0" but should have a
value of "0.8888888888888888".

I haven't been able to make this bug happen in DOS but it does occur in
Windows.

PLEASE DON'T call Borland - I already called this one in and they're working
on it.

The workaround is to write your own floating-point to ascii conversion
routine.  Unfortunately the other floating-point to ascii conversion
routines in BC++ 2.0 suffer from the same bug (at least the ones I tried -
fcvt, ecvt, gcvt, etc).

I've written a function to convert floats to the corresponding ascii string -
nothing fancy but it works.  If there is sufficient interest I'll post it.


Hope this message is useful,


Terrell
Technical Details
Message-ID: <1991Apr17.051133.23151@mnemosyne.cs.du.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mnemosyne.cs.du.edu!isis.cs.du.edu!ebergman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mnemosyne.cs.du.edu!isis.cs.du.edu!ebergman
From: ebergman@isis.cs.du.edu (Eric Bergman-Terrell)
Newsgroups: comp.windows.ms.programmer
Subject: BC++ 2.0 sprintf "%f" bug in Windows
Message-ID: <1991Apr17.051133.23151@mnemosyne.cs.du.edu>
Date: 17 Apr 91 05:11:33 GMT
Sender: usenet@mnemosyne.cs.du.edu (netnews admin account)
Reply-To: ebergman@isis.cs.du.edu (Eric Bergman-Terrell)
Organization: Nyx, Public Access Unix (sponsored by U. of Denver Math/CS dept.)
Lines: 33
Disclaimer1: Nyx is a public access Unix system run by the University of Denver
Disclaimer2: for the Denver community.  The University has neither control over
Disclaimer3: nor responsibility for the opinions of users.