Floating point handling #2

Open
opened 2026-03-26 19:12:46 -06: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 self-assigned this 2026-03-26 19:12:46 -06:00
laentropia added this to the Calculator project 2026-03-26 19:12:46 -06:00
laentropia moved this to To Do in Calculator on 2026-03-26 19:12:51 -06:00
laentropia added a new dependency 2026-04-13 10:15:56 -06:00
laentropia added the Kind/Enhancement
Priority
High
2
labels 2026-04-13 10:43:15 -06:00
laentropia added this to the First working version of calculator milestone 2026-04-13 10:43:22 -06:00
laentropia added a new dependency 2026-04-13 10:48:55 -06:00
Sign in to join this conversation.