https://github.com/zevv/fixedpoint
Fixed point math library
https://github.com/zevv/fixedpoint
Last synced: 11 months ago
JSON representation
Fixed point math library
- Host: GitHub
- URL: https://github.com/zevv/fixedpoint
- Owner: zevv
- Created: 2020-08-25T15:17:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-31T21:30:34.000Z (over 5 years ago)
- Last Synced: 2025-02-10T00:43:39.849Z (about 1 year ago)
- Language: Nim
- Size: 195 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Fixed point math lib, very much work in progress. Might or might not work.
## Usage
Define your custom fixed point types with the `defFixedPoint()` template:
``` Nim
defFixedPoint(, , )
```
This will create a type with the given name which can be used with some math
operations. Mixing different fixed point types in operations is someimes
supported.
Fixed point variables can be initialzed with floating point values at compile
time with the generated template `to` concatenated with the name of your type.
## Example
``` Nim
defFixedPoint(Speed, int8, 2)
defFixedPoint(Position, int16, 4)
var dx = toSpeed(1.25)
var x: toPosition(3.0)
x = x + dx
```