MS3 1.2.3 source code released
Moderators: jsmcortina, muythaibxr
Re: MS3 1.2.3 source code released
(Edit: huge post deleted because I figured out my problem... multiple brain farts while editing the .ini file. )
Eric Law
1990 Audi 80 quattro with AAN turbo engine: happily running on MS3+MS3X
2012 Audi A4 quattro, desperately in need of tweaking
Be alert! America needs more lerts.
1990 Audi 80 quattro with AAN turbo engine: happily running on MS3+MS3X
2012 Audi A4 quattro, desperately in need of tweaking
Be alert! America needs more lerts.
Re: MS3 1.2.3 source code released
Can I ask one more dumb question? This really relates to the C compiler used and not the MS code itself but I'm not quite sure where else to get the answer!
Suppose I write this code:
If the compiler uses 32-bit math, the above will return (in y) the desired result of 10000. If it uses 16-bit math, the (a + b + c + d) calculation will overflow and the result will be a negative number which of course would be bad.
So does anyone know which method the compiler will use? If it's the latter, would changing the calculation to "y = (long)(a + b + c + d) / 4" fix the problem?
Suppose I write this code:
Code: Select all
int a, b, c, d, y;
a = b = c = d = 10000;
y = (a + b + c + d) / 4;
So does anyone know which method the compiler will use? If it's the latter, would changing the calculation to "y = (long)(a + b + c + d) / 4" fix the problem?
Eric Law
1990 Audi 80 quattro with AAN turbo engine: happily running on MS3+MS3X
2012 Audi A4 quattro, desperately in need of tweaking
Be alert! America needs more lerts.
1990 Audi 80 quattro with AAN turbo engine: happily running on MS3+MS3X
2012 Audi A4 quattro, desperately in need of tweaking
Be alert! America needs more lerts.
-
- Super MS/Extra'er
- Posts: 884
- Joined: Sat Apr 30, 2011 12:34 pm
- Location: Sandefjord, Norway
Re: MS3 1.2.3 source code released
y = ((long)a+b+c+d)/4 should work, your code is not guaranteed to work since the conversion to long is optionally after the summation.
Joachim
1974 Jensen-Healey
1990 VW Caravelle Syncro - running MS3+X
2014 Ford Fiesta EcoBoost
1974 Jensen-Healey
1990 VW Caravelle Syncro - running MS3+X
2014 Ford Fiesta EcoBoost
-
- Site Admin
- Posts: 39615
- Joined: Mon May 03, 2004 1:34 am
- Location: Birmingham, UK
- Contact:
Re: MS3 1.2.3 source code released
Yes, the INPUT to an equation must be cast to a large enough variable so that the output will fit. While apparently illogical, this is correct C.subwoofer wrote:y = ((long)a+b+c+d)/4 should work, your code is not guaranteed to work since the conversion to long is optionally after the summation.
Casting the inputs to a larger type is particularly important for multiplication.
James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
Re: MS3 1.2.3 source code released
Great, thanks!
Eric Law
1990 Audi 80 quattro with AAN turbo engine: happily running on MS3+MS3X
2012 Audi A4 quattro, desperately in need of tweaking
Be alert! America needs more lerts.
1990 Audi 80 quattro with AAN turbo engine: happily running on MS3+MS3X
2012 Audi A4 quattro, desperately in need of tweaking
Be alert! America needs more lerts.