Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 08-21-2003, 12:28 AM   #1
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Red face

Is there any possible way to make a number that is larger than 2,147,483,647 on an LP mud?

Specifically:

Im running a heavily modified LPMud 2.4.5 on Amylaar driver...
Enziet is offline   Reply With Quote
Old 08-21-2003, 01:40 AM   #2
Ogma
Member
 
Ogma's Avatar
 
Join Date: Apr 2002
Home MUD: DartMUD
Posts: 86
Ogma is on a distinguished road
Well, there's always the floating point type, float. I'm not exactly sure what the maximum value a float can have but it's somewhere between 1x10^300 and 1x10^400 (it's implimentation dependent.) Of course, this doesn't give you same granularity as integers, but it will hold larger numbers. Also, floating point operations are significantly more CPU intensive. Finally, the driver you are using has to have floating point support compiled in.
Ogma is offline   Reply With Quote
Old 08-21-2003, 03:06 AM   #3
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Yeah I have tried using float but it is still the same, just lets me use decimals =/
Enziet is offline   Reply With Quote
Old 08-21-2003, 03:11 AM   #4
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Here are my testings...


> eval return "/sys/enziet.c"->conv( 2147483647 );
Got: "2,147,483,647"
> eval return "/sys/enziet.c"->conv( 2147483648 );
Got: "-2,147,483,648"
> eval return "/sys/enziet.c"->conv( 2147483649.9 );
Got: "2.,147,48e,+09"
> eval return "/sys/enziet.c"->conv( 2147483649 );
Got: "-2,147,483,647"
> eval return "/sys/enziet.c"->conv( 2147483648 );
Got: "-2,147,483,648"
> eval return "/sys/enziet.c"->conv( 2147483647 );
Got: "2,147,483,647"
> eval return "/sys/enziet.c"->conv( (long)2147483647 );
Error in compiling statement:
"exec_foo() { return "/sys/enziet.c"->conv( (long)2147483647 ); }
"*Error in loading object: 'players/enziet/EVAL'.

> eval return "/sys/enziet.c"->conv( (float)2147483647 );
Got: "2.,147,48e,+09"
Enziet is offline   Reply With Quote
Old 08-21-2003, 04:24 AM   #5
Ogma
Member
 
Ogma's Avatar
 
Join Date: Apr 2002
Home MUD: DartMUD
Posts: 86
Ogma is on a distinguished road
Well, yes...that's to be expected. What precisely are you trying to use this for?
Ogma is offline   Reply With Quote
Old 08-21-2003, 04:08 PM   #6
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Im tinkering around with making a MUD based on the Dragonball anime series... and well... the EXP is the 'powerlevel' and it seems squite easy, and needed, to get over 2bil... I just really dont want to end up using SMAUG or something, I'd much rather prefer LPC
Enziet is offline   Reply With Quote
Old 08-21-2003, 06:38 PM   #7
welcor
Member
 
Join Date: Apr 2002
Location: Aarhus, Denmark, Europe
Posts: 59
welcor is on a distinguished road
Send a message via ICQ to welcor
For very large numbers you can 'roll your own system'.

Pseudocode;
[code]
internally have 2 (or more vars)
int exp1
int exp2
int exp1_max = 100000;

When adding;
exp1+= add
while (exp1 >= exp1_max) {
 exp2++
 exp1 = exp1 - exp1_max
}
When displaying;
"You have %d%05d exp.", exp2, exp1
[/quote]

This will, by using two ints, allow for numbers approaching 214748364700000 (which is 214 trillion for you americans out there, and 214 billions to the rest of us. )

As a side note - even though I see that following the theme of dragonball is a main focus - I think a design that needs numbers in that range is absurd. There is nothing preventing you from just doing this:
[code]
"You have %d000 exp.", exp
[/quote]
When dealing with numbers up to 2.1 billion, you don't really care about those small changes below 1k, do you ? This little change should give you enough for the first 2k billions. (2 trillions) and doesn't give you any extra trouble.

In short - if you need such high numbers, your design is flawed.
welcor is offline   Reply With Quote
Old 08-27-2003, 02:54 AM   #8
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Actually, the only problem is displaying the numbers...

So I fixed it, and I can now display numbers far greater than I even know what to call them (200+ digits long).

Thanks for your help!
Enziet is offline   Reply With Quote
Old 08-27-2003, 07:57 AM   #9
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Enziet is offline   Reply With Quote
Old 08-27-2003, 11:04 AM   #10
kaylus1
 
Posts: n/a
I would have to agree, unless you are using down to the single digit then why not go with /10th or even /100th of what numbers you are trying to work with? I am unfamiliar with the Dragonball theme, so maybe it is needed.

Unless you find a trick to display the numbers, i'm not sure you will have much success. I don't currently know of any of the normal LPC servers that support big numbers.

Currently though, it isn't much of a problem with Pike, as it can be compiled with bignum support. =)

I'm sure my server written in Pike (GenLPC) could be modified to work with COMPAT mode mudlibs, but right now i'm attempting to get it to have a larger measure of compatibility with Native. Compat libs will require a load of simulated efuns to maintain compatibility, something I'm not keen to work on just yet.

Though the point still remains, do you -really- need numbers that large? )

Kaylus@Solice
  Reply With Quote
Old 08-27-2003, 03:24 PM   #11
welcor
Member
 
Join Date: Apr 2002
Location: Aarhus, Denmark, Europe
Posts: 59
welcor is on a distinguished road
Send a message via ICQ to welcor
200+ digits ? Why would ANYONE need numbers of that size ?
(to give an idea about just how absurd this is, consider the number of atoms in the universe is estimated at 1e79 (See for details.)

I remember back in high school we had a calculator program capable of 'unlimited length'* numbers. It could add, subtract and multiply, divide, calculate square root etc. . We used it to calculate pi to thousand decimals, to see if this high precision would allow for us to solve the circle/square problem (I don't remember the exact name, it's 15 years ago...) - of course the math program just showed us that no matter the accuracy, pi is still not expressable in decimal form. It also showed us that when you get past the first 10-12 digits, the rest is academic**.

Welcor

* limited by memory, which at the time was, I think, 64 or 128K.
** Academic = not worth it.
welcor is offline   Reply With Quote
Old 08-27-2003, 07:22 PM   #12
Enziet
New Member
 
Join Date: Jun 2002
Posts: 10
Enziet is on a distinguished road
Well, obviously it seems that Ido need numbers that large, probably wont need any past 500 trillion for a very long time...

Im not concerned as to WHY I need them, just figuring out HOW to use them...

Can I get more info on Pike?
Enziet is offline   Reply With Quote
Old 08-28-2003, 06:40 PM   #13
welcor
Member
 
Join Date: Apr 2002
Location: Aarhus, Denmark, Europe
Posts: 59
welcor is on a distinguished road
Send a message via ICQ to welcor
The large number calculator I mentioned in the earlier post, worked on strings (arrays of char), dynamically allocated to fit the size wanted - pseudo code:
[code]
string _add(string num1, string num2)
{
int i, j, s = 0;
string result, t1, t2;

if (strlen(num1) < strlen(num2)) {
t1 = num2; /* longest */
i = strlen(num2);
t2 = num1; /* shortest */
j = strlen(num1);
} else {
t1 = num1; /* longest */
i = strlen(num1);
t2 = num2; /* shortest */
j = strlen(num2);
}

for (;i >= 0 || s;i--, j--) {
if (j>= 0)
s = t1[j] + t2[i] + s;
else if (i >= 0)
s = t2[i] + s;

result[i] = s % 10;
s = s / 10; /*transfer extra */
}

return result;
}
[/quote]

This method (or something similar - the above is mailer code) can be used for all wanted calculations. To output this string afterwards, just print it with a %s conversion.

Welcor
welcor is offline   Reply With Quote
Old 08-28-2003, 10:12 PM   #14
kaylus1
 
Posts: n/a
Pike is one of the faster "scripting"/interpreted languages. It is the brainchild of Fredrik Hübinette, after playing around on some LP muds a long while ago he decided to write his own dialect based on it and wrote a server (LPC4), it was still under the LP license agreement which meant that anything written for the dialect couldn't be used commercially. In 1994 Fredrik Hübinette started writing µLPC which grew and evolved into Pike.

Pike is a standalone scripting language with many similarities to LPC, with alot of builtin modules and some other features. It was a marked change from LPC though in that it doesn't have a server with it, just an interpreter. I had to write the server myself in Pike, which ended up working just as well. I learned alot about Pike that way.

It has all the data types: int, string, float, function, mapping, multiset, array, programming, object ( and all of the operators, as well as some neat ways to use them , operator overloading.. blah =) I gave the links.

Now to the point you like, the language can be compiled with bignum support to allow integers of arbitrary size. Exactly how big - I have not tested. Take this information from the unofficial FAQ

Hopefully that answers your question. To retreive Pike go to the and download the version you wish, I use 7.4.10 though it seems a new version is out. Another good thing about it, like most "scripting" languages is that it works on Win32, *nix, and various other environments with no changes. Which is great if you do most of your work from windows machines =) [Oddly, though, I still use Cygwin for my shell in windows.. heh]

Pike is more popular in europe, and hasn't taken hold in the U.S. like Python has. A few big projects, that I know of, have been made with Pike, most notably the Roxen Webserver.


*

If you are interested after taking a look at Pike, then just send me a message to and i'll be glad to talk with you about getting an alpha copy of my GenLPC and a small testlib, as well as whatever help you need =)

* Has a nice pro's and con's a few pages in.
  Reply With Quote
Old 09-14-2003, 10:53 AM   #15
Blobule
New Member
 
Join Date: Jul 2002
Location: Canada
Posts: 17
Blobule is on a distinguished road
I don't know what you're coding in, but my C compiler under linux supports
the 64 bit long long declaration:

long long i = 0;

I'm not sure what the endpoints are for 64 bits, but their probably more than
what you expect to need for a long time (way past trillions).
Blobule is offline   Reply With Quote
Reply


Thread Tools


longer numbers? - Similar Threads
Thread Thread Starter Forum Replies Last Post
Threshold is no longer pay-to-play. Threshold MUD Announcements 5 10-03-2007 09:07 AM
No Longer Moderator Ntanel MUD Announcements 0 11-06-2005 11:17 PM
No longer offering free avatar on Ancient Chaos Greetmir Advertising for Players 0 06-04-2005 03:15 AM
hex numbers Emit MUD Coding 2 10-01-2002 12:05 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 10:15 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2022