Floating point handling #2

Open
opened 2026-03-27 01:12:46 +00:00 by laentropia · 0 comments
Owner

What?

Right now the calculator can't handle any fractions or decimals, the plan is to implement it so that it can :).

How?

Well, there are two aproaches i want to have, first one would be to just allow floating pointers, we already have NODE_INTEGER for that so adding NODE_FLOATING or something like that and adding it to the union as well as adapting the lexer would be really easy. But, i want another approach too.

Instead of taking a floating point as literally that, we could have a Fraction type that stores the denominator and numerator, it would even have an algorithm for reducing itself for its minimal expression, handle 0 cases, could even extend to work as the division operator.

I would like to make the default to be use fractions instead of floating points so it will need to have the option to change that

# What? Right now the calculator can't handle any fractions or decimals, the plan is to implement it so that it can :). # How? Well, there are two aproaches i want to have, first one would be to just allow floating pointers, we already have NODE_INTEGER for that so adding NODE_FLOATING or something like that and adding it to the union as well as adapting the lexer would be really easy. But, i want another approach too. Instead of taking a floating point as literally that, we could have a Fraction type that stores the denominator and numerator, it would even have an algorithm for reducing itself for its minimal expression, handle 0 cases, could even extend to work as the division operator. I would like to make the default to be use fractions instead of floating points so it will need to have the option to change that
laentropia added this to the (deleted) project 2026-03-27 01:12:46 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
laentropia/Calculator#2
No description provided.