Typecasting or Integer Division?
by Justin Wright · in Technical Issues · 08/11/2012 (7:09 pm) · 2 replies
Is there any way to do integer division in torquescript? Or typecasting? Basically I just need the integer part of a division operation.
by Justin Wright · in Technical Issues · 08/11/2012 (7:09 pm) · 2 replies
Associate Chris Haigler
Jester Dance
function cropDecimal(%num) { %length = strlen(%num); %dot = 0; for(%i = 0; %i < %length; %i++) { if(getSubStr(%num, %i, 1) $= ".") %dot = %i; } if(%dot > 0) %name = getSubStr(%num, 0, %dot); else %name = %num; return %name; }The best (most performant) thing to do, provided you have access to the engine source code, would be to add a new ConsoleFunction to perform the truncation.