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 Discussion / Interesting math glitch

Author
Message
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Dec 2008 10:52 Edited at: 12th Dec 2008 11:04
I am sure this has been discussed before, but for some reason when I am calculating high numbers using exponents, it will suddenly give me an incorrect answer first going to negative, then 0.

Here is the number that gave me trouble:

30^9

Which gave a result of -834666496, which is clearly wrong.

I stumbled on it while experimenting with the taylor maclaurin polynomial for sin, curious to see if I could make a function that could calculate sin. Unfortunately, it doesn't seem to be feasible if I can't find a workaround for this glitch.

Anyone know anything about this?

[edit]
after some experimenting, I found that DBC has a problem handling VERY big numbers (specifically 10 billion and greater).

Try it:


Is there a way around this (besides dividing everything by 1 billion and keeping up with it later)?

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
jason p sage
19
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 12:08
LOL... this is probably that you're hitting the limits of that datatype. I THINK you're hitting the bit limit - and the jump from negative to positive is likely the sign bit (used in integers but not CPU native "unsigned" numbers) getting switched as you roll out of range..

You actually already decribed a decent solution... and this problem is not limited to DBPro. I have read about and seen source for more than one library of code designed specifically to make "custom data types" for numbers where they "chain" multiple integers together to serve as some super number datatype .. and they (authors of such API's) usually write routines to perform basic math on these large "homebrew" number data types.. and usually provide routines to convert strings to thiese data type values and back to make them usuable. Such a strategy in DBPro/DBC/etc.. would probably have to be homegrown however.

--Jason

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Dec 2008 17:04
@BN2

Take a look at :

DBC Largest Numbers

It may have some helpful information.

Enjoy your day.

Login to post a reply

Server time is: 2026-07-05 16:28:43
Your offset time is: 2026-07-05 16:28:43