Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problem with str$

Author
Message
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2002 18:53
a# = 2.55
print str$(a#)

why do I get 2.5499999523162842

I presume this is just a precision error in way real numbers are stored.

Is there a way round this?
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2002 19:11
You could always add 0.005 ie :

a#=2.55
print str$(a#+0.005)

Yes, I really am THAT good...
dARKNER
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: Sweden
Posted: 24th Oct 2002 19:21
a#=2.57 : print str$(a#+0.000005) = 2.57
is more like it ...

@MrTAToad .. ..
(a#=2.57 : print str$(a#+0.005) = 2.575)
----------

dUmb bug .. .. though don't see that it would stop me in my dev' ... .. Well I guess it would if I tried to make a sci-calculator .. lol ...

//dARKNER
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Oct 2002 02:25
erm your computer is odd i guess... as i get 2.55

Anata aru kowagaru no watashi!
dARKNER
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: Sweden
Posted: 25th Oct 2002 13:45
@Raven ...

What proc' do you have ? .. Just thought that it might be somethin dif between Intel & Amd .. .. I Have AMD ..

//dARKNER
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 13:59
I have AMD Athlon XP2000 and get these precision errors on loads of numbers. It is not just the str$ command either.
The following does the same:

a#=2.55 : print a#

Stupid or what!

OK, if I can't rely on accurate calculations, is there an easy way to format and round a number to 2 decimal places?

e.g

4.499999 = 4.50
0.1 = 0.10
-0.26666 = -0.27
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 14:16
Whats wrong with adding 0.005 ? Or does that generate the strange values ?

Yes, I really am THAT good...
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Oct 2002 15:41
The the machines i work on during the day use AMD based chips ... Optiron, AlthonXP and Duron
worked fine on all of them.
Also tested on my old Pentium works the same, there are alot of bug reports that i've been checking out recently and finding that most of them don't seem to apply to the computers i happen to be using.

However this bug might be caused by overclocking as the CPUs speed becomes more irratic when overclocked!
Be sure that you're processor is running a base value...
Also this may depend on Operating system, as I'm not longer running any OS other than XP (2660 - SP1), so perhaps older operating systems handle Pro a little differently. There is a number of reasons but to me seem extremely strange why my machine reports everything correctly. Only problem that has me baffled is the
Point(x,y) ... just doesn't work on red for odd reason!

Anata aru kowagaru no watashi!
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 16:27
I use completely unclocked AMD Athlon XP 2000 with Geforce4 Ti4600 and winXP home with new SP1. Also patched Dbpro with SP2.

I will try some other experiments over weekend to see if I can find a pattern.
Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 25th Oct 2002 17:00
I have the same problem.. very annoying.

The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th Oct 2002 05:50
patch 2.4 2.5499999523162842
patch 2FULL 2.55

http://www.lunarpixel.com/ is my new site
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 26th Oct 2002 15:14
With patch #2, I get 2.499999523... This is on an Intel processor.

Yes, I really am THAT good...
Farwalk
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location:
Posted: 26th Oct 2002 15:50
If some people are getting correct results after the patch and other folks are getting incorrect results after the patch, perhaps the problem is with the patching program. I noticed that when I run the updater that certain files will always still be version 1. When I run it for some files it will say:

DBProSetupDebug.dll no need to update.

and for other files it will say:

DBProVectorsDebug.dll was version 1 now updated.

It will continue to say this no matter how many times I run the Updater, suggesting that this file was not in fact updated. Are certain files not being updated by the patch when they should be? Below is a list of the dlls that exhibit this behavior:

DBProAnimationDebug.dll
DBProBSPCompilerDebug.dll
DBProBitmapDebug.dll
DBProInputDebug.dll
DBProMD2ObjectDebug.dll
DBProMD3ObjectDebug.dll
DBProMultiplayerDebug.dll
DBProPrimObjectDebug.dll
DBProSoundDebug.dll
DBProSystemDebug.dll
DBProVectorsDebug.dll

-Farwalk

Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 26th Oct 2002 18:35
indi:

"patch 2.4 2.5499999523162842
patch 2FULL 2.55"

If I got it right.. patch 2.4 has this bug, but 2FULL doesn't. Has this patch 2.4 been here on DBPro homepage?
Because I downloaded the patch 2 from here straight after I heard it has been uploaded.

The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th Oct 2002 18:46
I think patch2 full is available for all not sure.

http://www.lunarpixel.com/ is my new site
NTekk
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 26th Oct 2002 19:10
Having the same problem, also after installing patch 2
one of my programs quit running. At first I thought it
was glueing limbs....but I traced it down to a string
comparison line!
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 27th Oct 2002 00:59
I give up!
De-installed dbpro on 2 differenct pc's and re-installed from scratch.
pc1 = Win98,P3 500
pc2 = WinXP,Athlon XP 2000

Fresh install of dbpro with no patches, both pcs give correct answer when simply saying:
print 2.55 : wait key

After patch 1, both still give correct answer

After patch 2, pc1 still correct but pc2, my main pc, gives incorrect answer.

Anyone see any logic?

As far as I can tell, everything patched correctly with no errors.

Login to post a reply

Server time is: 2024-03-28 10:12:22
Your offset time is: 2024-03-28 10:12:22