Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
64 Bit's in QB?
#11
Ask Neo! He'll tell ya how he did BIGINT (string numbers).
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#12
Too bad you dont want to use C/C++. I think you just need to declare unsigned long long int or something to get a 64bit variable ^^ =P.
Reply
#13
Thanks all for recommending BIGINT Wink Well Z!re, just ask away... Wink

And btw,
Quote:Using strings, how do I get it to not take 2sec per operation?
Try for yourself. At my place, it can calculate 2 ^ 32000 in a number of seconds... Wink

Here's the link to HAR-SoftWare's download page: http://www25.brinkster.com/harsoftware/d-libraries.htm
Reply
#14
A string being a collection of 8 bits *and* the fact that you're prolly using "0123456789" to represent numbers in them, 32 or 64 bit calculations are a lot more efficient...

Oh well.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#15
You mean 32/64bit operations are far more efficient when done with strings?
Reply
#16
Quote:Try for yourself. At my place, it can calculate 2 ^ 32000 in a number of seconds...
I have tried it :wink:

Code:
n1$ = "2"
n2$ = "1000"

t! = TIMER
PRINT SI.Power(n1$, n2$)
PRINT TIMER - t!

Time taken 2.0seconds

I did try 2^32000, I gave up after letting it run for about 2min

What kind of computer do you have?, I'm running this on a 850mhz 128mb ram.
Reply
#17
Quote:You mean 32/64bit operations are far more efficient when done with strings?

No, I mean that 32-bit computations are far more efficient than 8-bit computations that only actually use 4 bits. (0 to 9 takes 4 bits)

"strings" of 32-bit computations are also preferred to strings of 8-bit computations. It's a lot harder to implement LONGs in doing large accurate computations than strings, though. Even in non-QB, you have to convert the input number string into bit representations and then convert the output bit representation back into a string.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#18
ah! i thought so. There are too many complexities if you look at it. Some properties will speed up the operation while others will slow it down Wink.
Reply
#19
Quote:
Neo Wrote:Try for yourself. At my place, it can calculate 2 ^ 32000 in a number of seconds...
I have tried it :wink:

Code:
n1$ = "2"
n2$ = "1000"

t! = TIMER
PRINT SI.Power(n1$, n2$)
PRINT TIMER - t!

Time taken 2.0seconds

I did try 2^32000, I gave up after letting it run for about 2min

What kind of computer do you have?, I'm running this on a 850mhz 128mb ram.
Hehe Wink I have a AMD Athlon XP 2400+ with 512 MB RAM (2.0 GHz). I can run it again, to see how long it takes on my comp.

Anyway, about BIGINT, short calculations like 31130581380334 * 4018810580510 are very fast, while long calculations like 2 ^ 32000 can take a few mins on slower comps. It is with BigInt as well, in combination with NeoLib, that I was able to calculate a few prime numbers in the far region of numbers (like 2 ^ 32000). Using NeoLib only I could define all prime numbers up to 10,000,000 in 170 seconds. Wink

Oracle tried to upgrade BIGINT to something like BIGDEC(IMAL) with support for negatives and decimals as well. However, he encountered a lot of problems and bugs. Sad Perhaps I'll try to continue his work some day.

Anyway, I hope you like BIGINT and that it can suit you on some calculations you need. Wink


Quote:ah! i thought so. There are too many complexities if you look at it. Some properties will speed up the operation while others will slow it down .
Indeed. With strings however this can be done fast as well, since every character is 8 bit. Just do ASC(Number$) - ASC("0") to calculate the number representative of a string number, when you don't want to use VAL(Number$) that is. Wink Another advantage of using 8 bit is that you don't need to calculate advanced positions in the number, a problem you do have when using nibbles to represent a number. The question you e.g. might run into then are 'Which byte should I store a number to?' and 'Which part of the byte should the number be in? Hi or Lo?'. To avoid extra work I used strings.

But... in theory, it can be done more efficiently with nibbels. Moreover, the maximum values of a BIGINT increases then to 65536 numbers. But don't expect 2 ^ 64000 to take a few seconds when using nibbles! Big Grin
Reply
#20
It's called currency, and internally its a 64 bit signed integer. It is displayed with a decimal point however, and the last four digits are assumed to be behind the decimal point (making it ideal for financial calculations), but if you display it as a string and remove the decimal, you can easily use it's full range just by adjusting the decimal.

Jonathan Simpson
onathan Simpson
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)