Game Maker Community: Bigint Released! - Game Maker Community

Jump to content

This forum provides a place to post your Dlls, Scripts, Libraries and Extensions for GM. Be sure to read these rules prior to posting. The guidelines for each sub-forum are pinned at the top of that forum.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bigint Released! calculate really big numbers!

#1 User is offline   Rithiur 

  • GMC Member
  • Group: Local Moderators
  • Posts: 89
  • Joined: 04-October 03

Posted 21 August 2005 - 03:37 PM

A little while ago in some random thread, I read someone saying "I wonder if anyone has figured out how to count really big numbers", and so I was inspired to create this: The BigInt Lib.

It's a set of GML scripts that allow you to calculate bigger numbers, than what GM is capable itself with real values. The numbers are also very accurate, unlike GM, which suffers from weird inaccurate real values. The scripts, however, tend to be a bit on the slower side. Because all the calculation is done manually in pieces, it is going to take a lot more time. So, multiplying like a hundred numbers by itself will take several seconds to calculate.

Mainly the library is meant for like purposes where you need to have like large scores, and the GM's real values don't just provide enough accuracy for you.

Anyway, get it here:
http://koti.mbnet.fi/rithiur/risc/download...le. php?k=bigint

Sorry, but there is no example provided with it, as I was too lazy to actually make one. But you try something like importing the bigint.gml to a new game and then putting the following script in the room creation code:

CHUNK_SIZE = 6;
num1 = bi_new_string("12345678912345");
num2 = bi_new_string("98765432198765");
result = bi_multiply(num1, num2);
show_message(bi_to_string_format(result, " "));
game_end();


EDIT: Oh, and I should mention: I haven't tested the library too much. It's more in the state of "it seems to work", but I have no guarantees. Even just before submitting this I found new bugs. So if you find any bugs in it, please let me know.

Oh, and bug reports, suggestions and comments are more than welcome.

This post has been edited by Rithiur: 21 August 2005 - 08:22 PM


#2 User is offline   Cynical 

  • Inside the Cynic
  • Group: GMC Member
  • Posts: 423
  • Joined: 13-October 04

Posted 21 August 2005 - 07:52 PM

It seems to work nicely, although I doubt I will need it because I have never run into any problems with GM's built-in mathematical..-ness. Good work, I wish I had a good reason to use it :).

EDIT: I ran into an error running your example code ... 1 sec, I'll take a screenshot of it.

EDIT 2: Here's the error I got

This post has been edited by Cynical: 21 August 2005 - 07:56 PM

0

#3 User is offline   Rithiur 

  • GMC Member
  • Group: Local Moderators
  • Posts: 89
  • Joined: 04-October 03

Posted 21 August 2005 - 08:22 PM

Quote

EDIT: I ran into an error running your example code ... 1 sec, I'll take a screenshot of it.

Ah, yes. I forgot to mention that you will need to create a constant CHUNK_SIZE and give it value 6. Sorry about that. (or you could alternatively set a variable CHUNK_SIZE with value 6, it doesn't really matter). I've updated the code there.

#4 User is offline   TJ 

  • GMC Member
  • Group: GMC Member
  • Posts: 30
  • Joined: 25-June 04

Posted 21 August 2005 - 11:25 PM

I will play around with these. But I would like to see decimal places possible now.
0

#5 User is offline   Rune Hunter 

  • GMC Member
  • Group: GMC Member
  • Posts: 317
  • Joined: 05-July 04

Posted 22 August 2005 - 12:11 AM

Game Maker uses 6 byte float values. The only bigger you can get is like a 12 byte float or a double varaible.

It will than throw it into sientific notation if the number exceeds maybe 16 digits. Floats are not the most acurate for HUGE numbers, other wise it will sufice for most things.

Other wise I havn't tested this but good idea, maybe make a dll though, people say they run faster.
0

#6 User is offline   Smarttart62 

  • designFUSION™
  • Group: GMC Member
  • Posts: 2619
  • Joined: 19-November 03

Posted 22 August 2005 - 02:26 AM

Hmm still pointless though for me, but nice idea i guess
-Steve
0

#7 User is offline   Bathy 

  • GMC Member
  • Group: GMC Member
  • Posts: 504
  • Joined: 10-July 04

Posted 22 August 2005 - 09:45 AM

Rune Hunter, on Aug 21 2005, 05:14 PM, said:

Game Maker uses 6 byte float values.


Is it not 4 bytes?

This post has been edited by Bathy: 22 August 2005 - 12:16 PM

0

#8 User is offline   lelo707 

  • GMC Member
  • Group: GMC Member
  • Posts: 258
  • Joined: 04-February 04

Posted 24 August 2005 - 09:23 AM

Exellent work, as usual. Extremely good programming.
I admire your work alot, but I think the reason you don't usually get many replies in your topics is that your projects aren't incredibly useful (the exeption being your menu system, which is fantastic :wacko: ). Like you said, it could be used for really big scores, but you could also just add "+'000'" to your score drawing code and you would have basically the same effect. Maybe you should try making a game yourself, as you are without doubt a very capable programmer. On the other hand, the projects you make seem to me not inspired by the fact that they're a necessary addition, but more as a challenge. I have also done a few projects like these. (objects without using the built in system, multiple values in one variable, debug scripts)

Good luck with this, but don't be too dissappointed if you don't get many replies. This is simply the wrong community to post this kind of thing.
0

#9 User is offline   takua108 

  • GMC Member
  • Group: GMC Member
  • Posts: 578
  • Joined: 01-November 03

Posted 24 August 2005 - 02:53 PM

Agreed. This is more of a "techincal" thing, and people will be more for looking at the next big multiplayer library. Decimal places would be cool, though. Anyways, awesome work!
0

#10 User is offline   Rithiur 

  • GMC Member
  • Group: Local Moderators
  • Posts: 89
  • Joined: 04-October 03

Posted 24 August 2005 - 06:52 PM

Yeah, you are right. I've done most of my scripts simply because I found them interesting "challenges". It's no fun coding something that very simple and easy to do. Things that are tricky are so much more fun to do, which is also mostly the reason I haven't gotten into making games.

You see, making good games is mostly a bit boring work. When you want to have good finished work, you'll have to pay a lot of attention to small finer details and things that are realitively easy to program, but still require work. For example, just making a simple main menu can be quite boring. You have buttons there, and if you click them something happens, or maybe the menu is controlled by keys. All very simple things, but yet mandatory and essential for a good finished game.

Also, in addition to that, games take very long to make. My attention span is not usually enough to be able to concentrate through big projects like that. In the middle I already have many better ideas to do and so they just end up never getting even really started. Scripting projects on the other hand are interesting and can keep me occupied, as the documentation is usually the only boring part.

Also, I've never done any music in my life, so I know nothing about that and I'm also horrible at graphics, so my games would look bad, even if the coding was good.

But still, I currently have been planning about making one game, and planned it out pretty well already. We'll see if that will turn into anything. I'm trying to plan the project so that IF I do happen to get it finished, I can "hire" a graphical artist in the end to redo the graphics in the game. But that will have to wait. All there is now, is the loading screen and simple background for rooms.

Quote

Like you said, it could be used for really big scores, but you could also just add "+'000'"

Yep. The precision offered by my script is rarely needed in any games, or anywhere at all. Even really the only game that I can come up with, that would have needed bigger numbers is Transport Tycoon. It used to be annoying that when you got enough money, the sum would go to negative, because the int limit was reached :(

And honestly, you could almost say that game needed that precise numbers is badly planned.

Quote

Good luck with this, but don't be too dissappointed if you don't get many replies. This is simply the wrong community to post this kind of thing.

One good reply like that, makes it feel all worth it, though :wacko: (and honestly, this was just a 2 night project, so it's not that big)

#11 User is offline   tsg1zzn 

  • GMC Member
  • Group: GMC Member
  • Posts: 1163
  • Joined: 16-November 03

Posted 27 August 2005 - 08:27 PM

Bathy, on Aug 22 2005, 11:48 AM, said:

Rune Hunter, on Aug 21 2005, 05:14 PM, said:

Game Maker uses 6 byte float values.


Is it not 4 bytes?
<{POST_SNAPBACK}>

No, it's 8. :( 15–16 significant digits.
0

#12 User is offline   IsmAvatar 

  • Good Samaritan
  • Group: GMC Member
  • Posts: 2247
  • Joined: 12-October 03

Posted 27 August 2005 - 11:34 PM

actually, GM's poor precision is a hinderance to date-time functions. It also makes it difficult to store/retrieve 4 bytes (longint) to/from a file.

I've been working on a set of scripts myself. So far only addition and subtraction work. They do account for negative numbers and decimals.

Unfortunately, my hard drive crashed about a week after starting the project, and it was lost. Whenever I get a chance, i'll remake it. It will have the following features:
> Addition
> Subtraction
> Multiplication
> Exponents
> Division (precision specified)
> Modulus
> Rounding (floor, ceil, round)

it is doubtful that I will be able to do roots. If I do, I'll probably create an inefficient method compared to some that i've seen. You'd have to specify precision.

It is also doubtful that this will be done anytime soon. Maybe about a month from now, unless someone beats me to it.
0

#13 User is offline   JJProductions 

  • Agamma Corpus
  • Group: GMC Member
  • Posts: 2211
  • Joined: 23-January 05

Posted 28 August 2005 - 12:02 AM

Jeez, everyone knows that GM uses DOUBLE FLOAT variables.
0

#14 User is offline   Chirantha 

  • GMC Member
  • Group: GMC Member
  • Posts: 502
  • Joined: 15-February 05

Posted 27 September 2005 - 02:43 PM

This Thing is Very Useful. Its shame that GTA2 forgot to use somthing like this because the score doesn't go more than 99999999. Err....

Well I will try to contact Rockstar Games and tell them to convert and use this script for the next GTA Version. ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users