Menu

#86 Symbolic data types

0.6.5
open
nobody
None
2015-11-30
2015-11-30
Sp3000
No

This one's a major stretch since it'll require a lot of work and rewriting to implement, but I thought I'd add it here as something to consider.

Instead of true floats, all "float" values are secretly symbolic on the back end, e.g. cos(1) would actually just be cos(1), instead of 0.5403023058681398. Possible accompanying operators include:

  • Popping x, n and printing x rounded/truncated to n sig figs/decimal places
  • Popping x rational and pushing its numerator and denominator

Otherwise, values are converted back to float before being output.

The main advantage would be that floating point precision never gets in the way of most problems, e.g. Fibonacci numbers can be calculated with the golden ratio formula (not the golfiest way for CJam, but just an example). The main disadvantages, of course, would be a slower language and a lot of implementation work.

Discussion


Log in to post a comment.