Removing Scientific Gibberish From Big Numbers

Expanding and utilizing the engine via C++.

Removing Scientific Gibberish From Big Numbers

Steve_Yorkshire
Posts: 215
Joined: Tue Feb 03, 2015 10:30 pm

Many thanks to @
Bloodknight
for posting the original link. https://www.garagegames.com/community/resources/view/17059 from where I found Orion Elenzil's original post http://www.garagegames.com/community/resources/view/16983

Using math over 1,000,000 gives scientific herpyderpy:

echo(10000000 + 1);  1e+007

And 1e+007 isn't real helpful ...

I updated the ConsoleFunctions into DefineEngineFunctions and slapped it all at the end of console/consoleFunctions.cpp.

//yorks from Orion ElenzilDefineEngineFunction(mAddS32, const char*, (S32 v1, S32 v2), , "Add 2 large numbers"){	S32 res = v1 + v2;	char* ret = Con::getReturnBuffer(64);	dSprintf(ret, 64, "%i", res);	return ret;}DefineEngineFunction(mSubS32, const char*, (S32 v1, S32 v2), , "Subtract 2 large numbers"){	S32 res = v1 - v2;	char* ret = Con::getReturnBuffer(64);	dSprintf(ret, 64, "%i", res);	return ret;}DefineEngineFunction(mMulS32, const char*, (S32 v1, S32 v2), , "Multiply 2 large numbers"){	S32 res = v1 * v2;	char* ret = Con::getReturnBuffer(64);	dSprintf(ret, 64, "%i", res);	return ret;}DefineEngineFunction(mDivS32, const char*, (S32 v1, S32 v2), , "Divide 2 large numbers"){	S32 res = v1 / v2;	char* ret = Con::getReturnBuffer(64);	dSprintf(ret, 64, "%i", res);	return ret;}

Known Issues:

Dividing rounds, so:
function testDiv(){   %a = 1234567;   %b = 3006780;   echo(mDivS32(%b, %a));}