<i>GOO</i> Manual -- Numbers

|  |  | Numbers

## Numbers

`<num>` | `(<mag>)` | `C`
`+` | `(x|<num> y|<num> => <num>)` | `G`
| returns the sum of its arguments. |
`-` | `(x|<num> y|<num> => <num>)` | `G`
| returns the difference of its arguments. |
`*` | `(x|<num> y|<num> => <num>)` | `G`
| returns the product of its arguments. |
`/` | `(x|<num> y|<num> => <num>)` | `G`
| returns the quotient of its arguments. |
`round` | `(x|<num> => <int>)` | `G`
| returns closest integer to `x`. If `x` is exactly between two integers then the implementation is free to return either integer. |
`round-to` | `(x|<num> n|<int> => <flo>)` | `G`
| returns `x` to closest flo `n` digits precision. |
`floor` | `(x|<num> => (tup <int> rem|<num>))` | `G`
| returns an integer by truncating `x` towards negative infinity. |
`ceil` | `(x|<num> => (tup <int> rem|<num>))` | `G`
| returns an integer by truncating `x` towards positive infinity. |
`trunc` | `(x|<num> => (tup <int> rem|<num>))` | `G`
| returns an integer by truncating `x` towards zero. |
`mod` | `(x|<num> y|<num> => <num>)` | `G`
| returns the remainder after taking the floor of the quotient of `x` and `y`. |
`div` | `(x|<num> y|<num> => <num>)` | `G`
| returns the trunc of the quotient of `x` and `y`. |
`rem` | `(x|<num> y|<num> => <num>)` | `G`
| returns remainder after dividing `x` by `y`. |
`pow` | `(x|<num> e|<num> => <num>)` | `G`
| returns `x` raised to the `e` power. |
`exp` | `(x|<num> => <num>)` | `G`
| == `(pow $e x)` |
`sqrt` | `(x|<num> => <num>)` | `G`
| returns the square root of `x`. |
`pos?` | `(x|<num> => <log>)` | `G`
| == `(> x 0)` |
`zero?` | `(x|<num> => <log>)` | `G`
| == `(= x 0)` |
`neg?` | `(x|<num> => <log>)` | `G`
| == `(< x 0)` |
`neg` | `(x|<num> => <num>)` | `G`
| == `(- 0 x)` |
`abs` | `(x|<num> => <num>)` | `G`
| == `(if (neg? x) (neg x) x)` |
`num-to-str-base` | `(x|<num> b|<int> => <str>)` | `G`
| returns string representation of `x` in base `b`. |
`num-to-str` | `(x|<num> => <str>)` | `G`
| equiv `(num-to-str-base x 10)` |
`str-to-num` | `(x|<str> => <num>)` | `G`
| returns closest number corresponding to string `x`. |
`INCF` | `(INCF ,name)` | `S`
| == `(SET ,name (+ ,name 1))` |
| `(INCF (,name ,@rest))` | `S`
| == `(SET (,name ,@rest) (+ (,name ,@rest) 1))` |
`DECF` | `(DECF ,name)` | `S`
| == `(SET ,name (+ ,name 1))` |
| `(DECF (,name ,@rest))` | `S`
| == `(SET (,name ,@rest) (+ (,name ,@rest) 1))` |
`$e` | `<flo>` | `I`
`$pi` | `<flo>` | `I`
`sqrt` | `(x|<num> => <num>)` | `G`
`log` | `(x|<num> => <num>)` | `G`
`logn` | `(x|<num> b|<num> => <num>)` | `G`
`sin` | `(x|<num> => <num>)` | `G`
`cos` | `(x|<num> => <num>)` | `G`
`tan` | `(x|<num> => <num>)` | `G`
`asin` | `(x|<num> => <num>)` | `G`
`acos` | `(x|<num> => <num>)` | `G`
`atan` | `(x|<num> => <num>)` | `G`
`atan2` | `(y|<num> x|<num> => <num>)` | `G`
`sinh` | `(x|<num> => <num>)` | `G`
`cosh` | `(x|<num> => <num>)` | `G`
`tanh` | `(x|<num> => <num>)` | `G`

### Integers

GOO currently represents integers as 30 bit fixnums.

`<int>` | `(<num>)` | `C`
`|` | `(x|<int> y|<int> => <int>)` | `G`
| returns the logical inclusive or of its arguments. |
`&` | `(x|<int> y|<int> => <int>)` | `G`
| returns the logical and or of its arguments. |
`^` | `((x|<int> y|<int> => <int>))` | `G`
| == `(| (& x (~ y)) (& (~ x) y))` |
`~` | `(x|<int> => <int>)` | `G`
| returns the logical complement of its argument. |
`bit?` | `(x|<int> n|<int> => <log>)` | `G`
| returns true iff `n`th bit is 1. |
`even?` | `(x|<int> => <log>)` | `G`
`odd?` | `(x|<int> => <log>)` | `G`
`gcd` | `(x|<int> y|<int> => <int>)` | `G`
| greatest common denominator. |
`lcm` | `(x|<int> y|<int> => <int>)` | `G`
| least common multiple. |
`<<` | `(x|<int> n|<int> => <int>)` | `G`
| returns `n` bit shift left of `x`. |
`>>` | `(x|<int> n|<int> => <int>)` | `G`
| returns signed `n` bit shift right of `x`. |
`>>>` | `(x|<int> n|<int> => <int>)` | `G`
| returns unsigned `n` bit shift right of `x`. |

### Floats

GOO currently only supports single-precision floating point numbers.

`<flo>` | `(<num>)` | `C`
`flo-bits` | `(x|<flo> => <int>)` | `G`
| returns bit representation as an integer. |

|  |  | Numbers