Difference between revisions of "Talk:Float2String"

From Second Life Wiki
Jump to navigation Jump to search
(New section: Errors with posted code)
Line 33: Line 33:


--[[User:Rhian Svenska|Rhian Svenska]] 16:11, 8 October 2008 (PDT)
--[[User:Rhian Svenska|Rhian Svenska]] 16:11, 8 October 2008 (PDT)
:I think I've fixed all but the last. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 20:11, 8 October 2008 (PDT)

Revision as of 20:11, 8 October 2008

Please be kind to totally review your text and code; examples are false, code is insufficiently implemented.

Examples: string myFormattedFloat = Float2String(-7.1373699,3,"Round"); //rounded returns -7.14

string myFormattedFloat = Float2String(-7.1373699,3,""); //not rounded returns -7.13

The real result is -7.137 for the both

Code:

   if (places == 0)
   {
       return neg + (string) ((integer)num );
   }

This is true if you want to truncate it, but false if you want to round it.

Other: To round it's written : "should be set to "Rounded" for Yes" in the expanations, //rnd (rounding) should be set to "Rounded" for Yes, "" for not rounded in a Comment Line and Yes in the code. Note that the wiki is first for people who want to study LSL.

Garmin Kawaguichi

Errors with posted code

  1. Code gives syntax error when copying/pasting code. (superfluous "else"?)
  1. Float2String(-123.456,0,FALSE) yields "--123". Should be "-123".
  1. Float2String(-123.456,0,TRUE) yields "-123.00000123". Should be "-123"

--Rhian Svenska 16:11, 8 October 2008 (PDT)

I think I've fixed all but the last. -- Strife (talk|contribs) 20:11, 8 October 2008 (PDT)