|
Corvis Anzac
Registered User
Join date: 7 Feb 2007
Posts: 3
|
05-15-2009 16:23
Hi I was looking for some help on a command or a simple way to trim a float (float as in a decimaled number) What i want to do is display something to the hundreths place like below.
example: 10.00
but what I get instead is a number like: 10.00000
i know that I could convert the float to a string then use something like llGetSubString(message, x, x); to cut off bits of it but I was looking for something more simplistic like an already built in command that would do the job.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-15-2009 17:03
There are no LSL functions available to do that.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-16-2009 13:17
yes, the only way to do it the string trick (although it doesn't need to be too painful.) with rounding vFltNumber = llRound( vFltNumber * 100 ) / 100.0; vStrNumber = (string)vFltNumber; integer vIdxPoint = 3; vStrNumber = llDeleteSubString( vStrNumber, vIdxPoint += llSubStringIndex( vStrNumber, "." ), -1 );
insert string would've worked better, but LL decided not to support negative indexes with it so it becomes an annoyance if you just want to remove trailing zeros.. if ((integer)vFltNumber == vFltNumber){ vStrNumber = (string)((integer)vFltNumber); }else{ vStrNumber = (string)vFltNumber; integer vIdxLast; @Loop; if (llGetSubstring( vStrNumber, --vIdxLast, vIdxLast ) == "0" jump Loop; vStrNumber = llGetSubstring( vStrNumber, 0, vIdxLast ); }
the last on I use in my own chat calculator
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|