Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Jul 09, 2009 3:43 am   

#MATH Question and limits
 
Ok, i'm sure that there's tons of posts that state where the limit of #math is, but for some reason i'm getting error's when looking at posts from the search.

2675000000
Is that to much of a # for #math to handle? 10 digits?

#MATH SRIslandTemp (@SRIslandCost/@SRIslandGain)
#VAR SRIslandCost {2675000000}
#VAR SRIslandGain {2000000}

on my calculator
2675000000 / 2000000 = 1337.5

According to zmud
2675000000 / 2000000 = 1073

I thought at first that it was because the cost and gain combined made to many #'s to i tried
2675000000 / 10 and got 214748364

Tried one 0 less on both
267500000 / 200000 = 1337
dropped the .5 for some reason. But since I can't even divide by 10 to get the one less 0, it don't matter.

There's no work around on this right?

I'm thinking of trying to code something that when i enter that I have X amount of $ it will run down the best possible purchases for me and increment the cost of the next purchase and continue on until i am out of money

Ex
I have $147,184,330,462

A nightclub costs me $21,500,000 and I gain $20,000 every hour
A Mansion costs me $103,950,000 and I gain $70,000 every hour
An Estate costs me $840,000,000 and I gain 650,000 every hour
A casino costs me $1,956,000,000 and I gain 1,500,000 every hour
An Island costs me $2,675,000,000 and I gain 2,000,000 every hour

Doing some math it boils down that buying a nightclub can earn me more $ than Mansion
70,000 / 20,000 = 3.5
21,500,000 * 3.5 = 75,250,000
So, 3.5 Night Clubs will cost me 75,250,000 and get me 70,000
while 1 Mansion will cost me 103,950,000 for the same 70,000

SO, what I wanted it to do was this
take the Cost / Gain for all of them, figure out which was the lowest #
1075 Club <---
1485 Mansion
1292.307692 Estate
1304 Casino
1337.5 Island

Echo to my screen which to buy
Deduct the cost from my $
Add the increase to the item bought (every item has a different increase, the gain never changes and only the item bought increases)

A nightclub costs me $21,550,000 and I gain $20,000 every hour
A Mansion costs me $103,950,000 and I gain $70,000 every hour
An Estate costs me $840,000,000 and I gain 650,000 every hour
A casino costs me $1,956,000,000 and I gain 1,500,000 every hour
An Island costs me $2,675,000,000 and I gain 2,000,000 every hour

And do the math again
1077.5 Club <---
1485 Mansion
1292.307692 Estate
1304 Casino
1337.5 Island

And keep at it until I have to little $ to buy anything.

BTW, not looking for the info to be displayed, just want to see what to purchase
Club
Club
Estate
Club

like that

But since I can't even get 2,675,000,000 to work, this seems fruitless Sad
Anyone know how to do this in Excel? Razz
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Jul 09, 2009 4:50 am   
 
By default, ZMud uses integer math so 19 / 10 = 1 as opposed to 1.9. Use 10.0 or %float(10) to use floating-point math. Also, ZMud is limited to 32-bit numbers, so I think you are limited to 268435455. Not sure I'm doing the math right, but it goes both negative and positive.

If you exceed this amount, the number "rolls over" to the other side of the number range and continues counting until the computer arrives at what it believes is the correct answer. Example:

1)given a variable type range of -10 to 10
2)given the equation 10 + 1

the answer supplied by the computer will be -10 instead of 11, because 11 doesn't fit into our variable.

P.S. Upgrade to CMud. It has bigger numbers (64-bit instead of 32-bit).
_________________
EDIT: I didn't like my old signature
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Jul 09, 2009 5:23 am   
 
awesome tip on the .0 !!

If I could afford CMud and know that i could transition without a headache and at least be able to print and read the code in zmud style i would.
But unfortunately, most or all of that criteria can't/won't be met Crying or Very sad
_________________
http://www.Aardwolf.com
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Jul 09, 2009 7:45 pm   
 
So, my question still remains...anyone know how to do all this in Excel? ;-)
yeah yeah, off-topic, but still :)
_________________
http://www.Aardwolf.com
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jul 09, 2009 8:03 pm   
 
Looking at all those numbers up there I notice that all of them have four zeros on the end that you can ignore. If this is the case with all the numbers you receive then using each of the captured numbers as strings take off the last four characters and then do your calculations.

#var spoon 1234567890000
#show %leftback(@spoon,4)

-> 123456789
_________________
Taz :)
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Jul 10, 2009 12:26 am   
 
or i could just edit the vars to not have the last 4 0's :-)
Thought of that last night as i was going to sleep. Hate when i do that cause i forget when i wake up then remember when someone points it out hours later.

The problem there is this

Money on hand: 147,184,330,462 <-- how much i have on hand is already part of the problem Wink
NightClub Cost: 21,500,000

Calculator: 147,184,330,462 - 21,500,000 = 147162830462

zMud:
#ADD @MoneyOnHand -@NightCCost
#ECHO @MoneyOnHand
147,184,330,462 - 21,500,000 = 2147483647

Crying or Very sad

I need to make the calculations based on what I have on hand. I don't know if left backing my on hand will be such a good thing.
_________________
http://www.Aardwolf.com
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Jul 10, 2009 12:27 am   
 
MattLofton wrote:
P.S. Upgrade to CMud. It has bigger numbers (64-bit instead of 32-bit).

What does that mean :-)
Like what's the highest #?
No idea about these things.
_________________
http://www.Aardwolf.com
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Jul 10, 2009 3:11 am   
 
hrmm.....thinking about this more....in reality, i don't NEED to have it do anything with my $....
it can just work on it's own for a loop of 10 or 20...
cut out the last few 0's and have it echo back a total current cost with the 0's added back in with this:
#echo @Purchase - @addcommas(@Spent),000 Spent so far

of course, i still need to figure our everything in the 1st place...havent really started to code it. just in the planning stages
_________________
http://www.Aardwolf.com
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Jul 11, 2009 2:38 am   
 
Quote:

What does that mean :-)


Ever worked with variables in a programming language like VB, C++, or Java (I'm not sure the same functionality exists in the scripting languages). Every variable type has two values that govern how much data you can store in the variable. The first value is usually reserved for the sign (- or +, though + usually equates to nothing at all). The second value is how much room the variable has for your data. By default, this range runs from -(range / 2) to +(range / 2 - 1), but if the language allows you to specify an unsigned number then the range becomes 0 to range (ZMud/CMud do not, so this part is moot). This is a little confusing, so here's an example:

Type: Integer, signed
range: 65536
lower boundary: -32768
upper boundary: +32767 (huh? The numbers don't add up because you have to account for 0)

If I create a variable of this type, the biggest number I can put into it is 32767. If I then try to add 1 to this, it rolls over and the number in the variable becomes -32768. If I instead added 100 the result would become -32669. For an unsigned integer, the same thing would happen once I went past 65536, with the extra reverting to 0 and counting from there.

ZMud was probably using something like a long integer, which if I recall has a range of like -2,147,483,648 to 2,147,483,647 (see? I knew I had the numbers wrong earlier.) CMud uses the int64 data type, which has −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 as a range.
_________________
EDIT: I didn't like my old signature
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Jul 11, 2009 2:49 am   
 
Heh, part 2. If you want to do math on your large numbers that are too large for ZMud, you can try doing it in VBscript/JavaScript. VBScript, at least, has a currency subtype for its variables that handles a range of 922-something trillion dollars. Since presumably you'll only be working with integer numbers, you will simply have to remove the .00 from the result.

I don't think %mss()/#MSS and zscript mix, however, so I'm not sure what it'll take to get your values into that part, but I suppose they take arguments that can be zmud variables.
_________________
EDIT: I didn't like my old signature
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net