Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002075Core InformEquations, units, arithmeticpublic2018-09-09 18:042018-09-10 20:48
Assigned To 
PlatformOS XOSEl CapitanOS Version10.11.6
Product Version6M62 
Target VersionFixed in Version 
Summary0002075: multiplying a multi-part unit by a real number yields absurd results
DescriptionWhen multiplying a multi-part unit, such as $1.99 specifying a cash-value, by a real number, such as 1.0, the result is some sort of integer overflow.
Minimal Source Text To Reproduce
Lab is a room.

Cash-value is a kind of value. $1.99 specifies a cash-value.

Holdings is a cash-value that varies. Holdings is $3.50.

When play begins: say "Number result: [2 times holdings]. Real number result: [2.0 times holdings]."
Additional InformationOutput: Number result: $7.00. Real number result: $11439308.80.

Possibly related to [^]

Forum thread: [^]

TagsNo tags attached.
Effect(serious/mild) Game compiles but misbehaves
Attached Files

- Relationships

-  Notes
zarf (developer)
2018-09-10 20:48

I think this is not related to 1935, after all. The generated code is

     tmp_0 = (REAL_NUMBER_TY_Times(1073741824, NUMBER_TY_to_REAL_NUMBER_TY((Global_Vars-->10))));

That is, it's converting the scaled value (pennies) to a real number, correctly multiplying that by 2.0 (using real multiplication), but then treating the resulting value as a scaled value again. It's missing the step where it converts the real back to an integer (pennies again).

- Issue History
Date Modified Username Field Change
2018-09-09 18:04 mattweiner New Issue
2018-09-10 20:48 zarf Note Added: 0004807
2018-09-10 20:48 zarf Status new => confirmed

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker