Closed sjbarag closed 6 years ago
I've marked this as "Good first issue" because we have a pretty good pattern around global functions now. Also note that -- because this is a first issue -- a first-time contributor doesn't have to implement all of these at once. That's a pretty big undertaking. We can always split this into multiple issues to handle families of math functions (e.g. "all the trigonometry functions", etc.)
Closing in favor of https://github.com/sjbarag/brs/milestone/3 now that I've split this out
The BrightScript language supports 17 global math functions:
Abs(x as Float) as Float
Atn(x as Float) as Float
Cdbl(x as Integer) as Float
Cint(x as Float) as Integer
Cos(x as Float) as Float
Csng(x as Integer) as Float
Exp(x as Float) as Float
Fix(x as Float) as Integer
Int(x as Float) as Integer
Log(x as Float) as Float
Rnd(range as Integer) as Integer
Rnd(0) as Float
Sgn(x as Float) as Integer
Sgn(x as Integer) as Integer
Sin(x as Float) as Float
Sqr(x as Float) as Float
Tan(x as Float) as Float
We should get those implemented! Luckily they seem to all be wrappers around JavaScript's
Math
native functions, so these should be relatively easy to implement as native functions. Also luckily: they all operate on eitherFloat
orInt32
, so we shouldn't have to worry about dealing with 64-bit integer math!