Skip to content

Fixed point type #109

@heinezen

Description

@heinezen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalpending discussion about something to dospecificationinvolves the nyan language specification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions