Re: abs function

new topic     » topic index » view thread      » older message » newer message

That's a pretty short way of doing it, but there is only one problem.  When
using atoms, finding the square and the square root of a number with lots of
decimal places will cause it to lose accuracy.  But, for integers, that way
is good.
  This will keep the accuracy by only changing the sign if necessary:

global function abs(atom x)
  if x < 0 then return  0 - x else return x end if
end function

Derek Brown

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu