Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed point type #109

Open
heinezen opened this issue Jun 29, 2023 · 0 comments
Open

Fixed point type #109

heinezen opened this issue Jun 29, 2023 · 0 comments
Labels
proposal pending discussion about something to do specification involves the nyan language specification

Comments

@heinezen
Copy link
Member

heinezen commented Jun 29, 2023

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.

  • fixed o fixed => fixed
  • fixed o int => fixed
  • fixed o float => ERROR
@heinezen heinezen added specification involves the nyan language specification proposal pending discussion about something to do labels Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal pending discussion about something to do specification involves the nyan language specification
Projects
None yet
Development

No branches or pull requests

1 participant