SFTtech / nyan

Typesafe hierarchical key-value database with inheritance and dynamic patching :smiley_cat:
Other
210 stars 30 forks source link

Fixed point type #109

Open heinezen opened 1 year ago

heinezen commented 1 year ago

nyan needs a built-in fixed-point type to handle safe arithmetics for fractional numbers. The implementation can be taken from the openage fixed-point implementation.

The type identifier could be fixed, fpdouble or doublefp. It can probably be hardcoded as a <int64_t, 16> fixed point (64 Bit signed, 16 Bit scale factor) which should be sufficient for most use cases.

ExampleObj():
    member : fixed = 1.25

The type could be compatible with the int type, and maybe with float if float is the left operand.