3 ms·
For example... Welcome to DrRacket, version 6.2 [3m]. Language: racket; memory limit: 128 MB. > (= (+ 0.1 0.2) 0.3) #f > (= (+ 1/10 2/10) 3/10) #t
by cicero 11y ago
For example...
Welcome to DrRacket, version 6.2 [3m].
Language: racket; memory limit: 128 MB.
> (= (+ 0.1 0.2) 0.3)
#f
> (= (+ 1/10 2/10) 3/10)
#t
- schoen 11y agoHow come a LISP allows you to write 1/10 instead of (/ 1 10)? Is it a special case for entering fractions, or does Racket allow arbitrary arithmetic expressions with infix operators?
- soegaard 11y ago1/10 is a literal. It denotes the value one tenth. The expression (/ 1 10) will at runtime calculate 1 divided by 10. Most programming languages have syntax for writing all available numbers as literals. Racket do not have builtin syntax for infix arithmetic - but there are various packages available for infix expressions.
- raiph 11y agoDo you know if there was ever any public discussion about whether to represent decimal fractions (0.1 etc.) as an exact rational or inexact float?
- soegaard 11y agoTake a look that the rrrs mailing list archive.
- raiph 11y agoThanks! Looks like bingo with my first search (a google for 'rrrs mailing list rational fraction float'): https://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1985/msg00016.html https://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrr... I've loved lisp's power since I first encountered it in the early 80s and also admired the great care put in to various aspects of Common Lisp (which is mentioned as the foundation for scheme's number decisions). Great stuff and still very relevant. :)