Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Akow), 1,371 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Variable accuracy for calculations #141867
07/18/07 14:39
07/18/07 14:39
Joined: Aug 2005
Posts: 119
Madison, WI
J
JakeL Offline OP
Member
JakeL  Offline OP
Member
J

Joined: Aug 2005
Posts: 119
Madison, WI
I am making an educational mathematic game. The game must have a calculator and be able to be as accurate with calculations as possible.

With the var I have found that when using decimals, the results are rarely accurate. I have scripted a calculator but had to remove decimal functionality due to the .2 being seen as .199. So, if the player multiplies .2 and 1 the answer on the calculator screen is “.199”! There are many other examples of this with other decimals. The manual does say calculations are inaccurate, but I wasn’t expecting the above to be true.

So what I guess I’m looking for is some help. Is there a workaround that can add accuracy? I need to add, subtract, multiply, divide, and take the square root on both the calculator and other calculations throughout the game. I would like accuracy to two decimals if possible. The engine always calculates the same which is good, but if the player compares the answers to a calculator, they are generally incorrect. This is not acceptable for a game which teaches math.

Would a .dll be what I’m looking for?

Re: Variable accuracy for calculations [Re: JakeL] #141868
07/18/07 14:43
07/18/07 14:43
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen


Always learn from history, to be sure you make the same mistakes again...
Re: Variable accuracy for calculations [Re: Uhrwerk] #141869
07/18/07 14:58
07/18/07 14:58
Joined: Aug 2005
Posts: 119
Madison, WI
J
JakeL Offline OP
Member
JakeL  Offline OP
Member
J

Joined: Aug 2005
Posts: 119
Madison, WI
Thanks for the link Zietwerk. I don't think scaling up for the calculator would do much good. For example, if the player types .2. Gamestudoio sees it as .199 than I multiply by 1000 and divide by 1000 and still end up with .199. It could work well for other calculations though.

Re: Variable accuracy for calculations [Re: JakeL] #141870
07/18/07 17:52
07/18/07 17:52
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Then you should probably change to Lite-C. The type "double" should provide much more accuracy.


Always learn from history, to be sure you make the same mistakes again...
Re: Variable accuracy for calculations [Re: Uhrwerk] #141871
07/18/07 22:51
07/18/07 22:51
Joined: Aug 2005
Posts: 119
Madison, WI
J
JakeL Offline OP
Member
JakeL  Offline OP
Member
J

Joined: Aug 2005
Posts: 119
Madison, WI
I've looked at Lite-c. Problem is the game is deep in development coded in c-script, about 10,000 lines. A7 is in beta now, but I need something that is relatively bug free. Thanks for the suggestion, though. Has anyone else found a work around for the accuracy issues?

Re: Variable accuracy for calculations [Re: JakeL] #141872
07/19/07 06:42
07/19/07 06:42
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
I suggest a simple dll for the maths.. just looks at the example dll and make some math functions that accept vars, convert them to doubles or floats, and return vars back.


Sphere Engine--the premier A6 graphics plugin.
Re: Variable accuracy for calculations [Re: Matt_Aufderheide] #141873
07/19/07 07:45
07/19/07 07:45
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
a7 is officially released, and relatively bug free.

in your case where conversion isn't an option, matt's suggestion is the best ^^

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Variable accuracy for calculations [Re: Matt_Aufderheide] #141874
07/19/07 10:33
07/19/07 10:33
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Quote:

make some math functions that accept vars, convert them to doubles or floats, and return vars back.



That won't help him a bit. It increases the accuracy of the results he gains, but if the result is 0.2 and that is converted back to the var type he gains 0.199 instead again. So the result will loose precision two times. The first time when converting from a string to var and the second time when converting from a double or whatever to var.

The only solution that really helps you is choosing one precise datatype and rewriting the code...


Always learn from history, to be sure you make the same mistakes again...
Re: Variable accuracy for calculations [Re: Uhrwerk] #141875
07/19/07 11:23
07/19/07 11:23
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
yeh whoops, i shoulda thought of that too but zeitwerk's right. unless you want to handle the entire calculator part in the dll.

julz


Formerly known as JulzMighty.
I made KarBOOM!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1