Merge pull request #48 from guzba/master

trunc instead of floor
This commit is contained in:
treeform 2021-12-03 13:00:29 -08:00 committed by GitHub
commit 414bdc8190
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -376,14 +376,14 @@ proc sign*[T](v: T): T =
proc quantize*[T: SomeFloat](v, n: T): T =
## Makes v be multiple of n. Rounding to integer quantize by 1.0.
sign(v) * floor(abs(v) / n) * n
sign(v) * trunc(abs(v) / n) * n
proc fractional*[T: SomeFloat](v: T): T =
## Returns fractional part of a number.
## 3.14 -> 0.14
## -3.14 -> 0.14
result = abs(v)
result = result - floor(result)
result = result - trunc(result)
proc mix*[T: SomeFloat](a, b, v: T): T =
## Interpolates value between a and b.