Verified:

Marshal Game profile

Member
32,589

Dec 14th 2013, 14:46:16

I put 4.1m bushels on market but game rounded it to 4,099,999 Bushels.

server is FFA.
Patience: Yep, I'm with ELK and Marshal.

ELKronos: Patty is more hairy.

Gallery: K at least I am to my expectations now.

LadyGrizz boobies is fine

NOW3P: Morwen is a much harsher mistress than boredom....

qzjul Game profile

Administrator
Game Development
10,270

Dec 14th 2013, 19:15:13

interesting; could be part of the RAM issue; working on a way to solve that without taking EE down.

Don't think it's code though.
Finally did the signature thing.

Marshal Game profile

Member
32,589

Dec 14th 2013, 20:39:14

only 1 country got that weird rounding.
Patience: Yep, I'm with ELK and Marshal.

ELKronos: Patty is more hairy.

Gallery: K at least I am to my expectations now.

LadyGrizz boobies is fine

NOW3P: Morwen is a much harsher mistress than boredom....

Xinhuan Game profile

Member
3728

Dec 15th 2013, 10:33:29

This isn't actually a bug, but more to do with how computers store numbers. The number "4.1" cannot be stored exactly because it cannot be calculated as an exact power of 2 (whereas 0.5 = 2^(-1) or 1.5 (= 2^0 + 2^(-1)) can be). So the "4.1" string is first converted into a double, which stores it as 4.09999999999999964472863211995e0. To multiply by 1m, the integer is first promoted to a float from 1000000 to 1e6, so the 2 operands are of the same type. Multiplying by 1e6 (1 million) gives 4.09999999999999953433871269226e6 which when converted to an integer is 4099999. Conversion to integers (whether explicit or implicit) is a "round towards zero" operation where the decimal part is truncated, it is not the same as "round towards nearest integer" which is implemented as (int)(x+0.5) for positive numbers and (int)(x-0.5) for negative numbers.

braden Game profile

Member
11,480

Dec 15th 2013, 13:09:43

personally, i'ma take his word for it :P

Marshal Game profile

Member
32,589

Dec 15th 2013, 16:53:23

6.3m and others between 3 and 6.3 were successfully put on market w/o rounding.

*kicks xin* stop posting those weird formulas.
Patience: Yep, I'm with ELK and Marshal.

ELKronos: Patty is more hairy.

Gallery: K at least I am to my expectations now.

LadyGrizz boobies is fine

NOW3P: Morwen is a much harsher mistress than boredom....

crest23 Game profile

Member
4666

Dec 15th 2013, 18:47:03

Originally posted by Xinhuan:
This isn't actually a bug, but more to do with how computers store numbers. The number "4.1" cannot be stored exactly because it cannot be calculated as an exact power of 2 (whereas 0.5 = 2^(-1) or 1.5 (= 2^0 + 2^(-1)) can be). So the "4.1" string is first converted into a double, which stores it as 4.09999999999999964472863211995e0. To multiply by 1m, the integer is first promoted to a float from 1000000 to 1e6, so the 2 operands are of the same type. Multiplying by 1e6 (1 million) gives 4.09999999999999953433871269226e6 which when converted to an integer is 4099999. Conversion to integers (whether explicit or implicit) is a "round towards zero" operation where the decimal part is truncated, it is not the same as "round towards nearest integer" which is implemented as (int)(x+0.5) for positive numbers and (int)(x-0.5) for negative numbers.


Please explain that again, but this time, use the actual number, 4100000. Not 4.1, lol.
The Nigerian Nightmare.

h2orich Game profile

Member
2245

Dec 16th 2013, 8:55:23

I have occasions where my $ were like 15,234,235.66666667. Makes me look rich, except thats a . not ,

https://dl.dropboxusercontent.com/...1/IMG-20131004-WA0016.jpg

Edited By: h2orich on Dec 16th 2013, 8:57:55
See Original Post

Xinhuan Game profile

Member
3728

Dec 16th 2013, 11:52:10

Originally posted by crest23:
Please explain that again, but this time, use the actual number, 4100000. Not 4.1, lol.


I can't do that, because the user explicitly typed in "4.1m" in the textbox, which means the number that the computer has to interpret is "4.1", followed by a "m".

Because of the way computers store numbers, 4.1 is really stored as 4.09999999999999964472863211995. After multiplying by 1m and rounding down the result of the multiplication _towards_ 0, this becomes a final value of 4099999.

Is this now simple enough to understand? Basically, numbers with decimal parts cannot be stored _exactly_, unless it can be decomposed and added up by fractional powers of 2. (i.e, 0.5, 0.25, 0.125, etc). Obviously, if the user actually typed in "4100000" instead of "4.1m", this wouldn't be a problem.

Edited By: Xinhuan on Dec 16th 2013, 11:56:02
See Original Post

Atryn Game profile

Member
2149

Dec 16th 2013, 13:06:16


Wait, what? You can type "4.1m" on the market instead of having to type out "4100000"?

If that is true, I never knew that shortcut.

Xinhuan Game profile

Member
3728

Dec 16th 2013, 15:31:06

Yep. You can also use "k" to multiply by 1000. Works in almost any EE textbox that accepts numbers.

blid

Member
EE Patron
9319

Dec 16th 2013, 16:43:28

Wow that's amazing, I never knew that before either. I remember in BRE you could do it, you press M or K and the right number of zeros would just pop up. That's cool.
Originally posted by Mr. Titanium:
Watch your mouth boy, I have never been accused of cheating on any server nor deleted before you just did right there.

Marshal Game profile

Member
32,589

Dec 16th 2013, 21:04:27

5.1m bushels went to market as 5.1m but 4.1m went as 4.099,999 bushels so why 5.1 doesn't get rounded? or 6.3 or 5.5 or .....
Patience: Yep, I'm with ELK and Marshal.

ELKronos: Patty is more hairy.

Gallery: K at least I am to my expectations now.

LadyGrizz boobies is fine

NOW3P: Morwen is a much harsher mistress than boredom....

Marshal Game profile

Member
32,589

Dec 27th 2013, 23:16:01

twice 1 country spent 1 buck less than others when buying bushels, 1st time then 10m and then 3m.
Patience: Yep, I'm with ELK and Marshal.

ELKronos: Patty is more hairy.

Gallery: K at least I am to my expectations now.

LadyGrizz boobies is fine

NOW3P: Morwen is a much harsher mistress than boredom....