View Single Post
  #17  
Unread 12-05-2008, 06:04 PM
SOE-Rothgar SOE-Rothgar is offline
A Griffon
Yes this person is from Daybreak!
 
Join Date: Aug 2007
Server: Unrest
Posts: 208
Default

I was just implementing the abs() function and had an idea.

I am making this function work for floating point numbers, so I take the value passed into abs() and parse it as a float. After calculating the absolute value I have to turn the float back into a string. This has the unfortunate side effect of doing what all the other math functions would do.

so... abs(-4) would output 4.000

I decided to modify our floating point parser which currently takes a precision value (defaults to 3) and make it so I can pass a precision of -1 to indicate that it should not use trailing spaces. So now abs(-4) equals "4" while abs(-4.5) would still equal "4.5".

Now to the interesting part. I got to thinking that there's no reason why the output of the math functions should always return a precision of 3. If anything it should use this new change I made and only return the precision necessary. So 4 + 5 = "9" and not "9.000". 2 / 4 would = "0.5" and not "0.500".

So my question is, would this mess any of your mods up? Are there situations where you are relaying on a precision of 3 by default?

Oh, one other thing. I found a bug that was fixed. Wanted to give you a heads up in case this would affect you.
Currently if you try to use a negative floating point number in script, it will stop parsing the number when it hits the period. I've fixed this so now you write -4.5 and it'll work instead of returning -4.

Last edited by SOE-Rothgar : 12-05-2008 at 06:08 PM.
Reply With Quote