### algebraic operations coercion rules for results

Posted:

**Sun Apr 07, 2019 9:19 am**since I feel that the best way to learn a language is to write an interpreter/compiler for it

I am trying to write a simple scheme interpreter

a silly example of why I am asking the question

the result

is there a logic behind the switch to scientific notation for

or the coercion is only an implementation detail ?

cheers

G

PS

the above from chez scheme 9.5

even if with different magnitudes something similar happens at

https://repl.it/languages/scheme

BiwaScheme Interpreter version 0.6.4

( + 0 0.000001) ==> 0.000001

( + 0 0.0000001) ==> 1e-7

I am trying to write a simple scheme interpreter

**where**can I find the coercion rules for algebraic/arithmetic operations ?a silly example of why I am asking the question

Code: Select all

```
( + 0 0.01 )
( + 0 0.001 )
( + 0 0.0001 )
( + 0 0.00001 )
( + 1 0.01 )
( + 1 0.001 )
( + 1 0.0001 )
( + 1 0.00001 )
```

Code: Select all

```
> 0.01
> 0.001
> 1e-4
> 1e-5
> 1.01
> 1.001
> 1.0001
> 1.00001
```

**( + 0 0.0001 )**or the coercion is only an implementation detail ?

cheers

G

PS

the above from chez scheme 9.5

even if with different magnitudes something similar happens at

https://repl.it/languages/scheme

BiwaScheme Interpreter version 0.6.4

( + 0 0.000001) ==> 0.000001

( + 0 0.0000001) ==> 1e-7