
Ask HN: Why is #e#x+e#s+e-e#l-e a valid number in Racket? - sillysaurus3
Eli Barzley pointed out that Racket reads #e#x+e#s+e-e#l-e as a number.[1]<p><pre><code>  $ racket
  Welcome to Racket v6.10.
  &gt; #e#x+e#s+e@-e#l-e
  16140901064495857664-50176i

</code></pre>
Why is it valid? According to <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;reference&#x2F;reader.html" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;reference&#x2F;reader.html</a>, #s should be a structure literal.<p>I suppose this would be better as a StackOverflow question, but it&#x27;s an interesting puzzle.<p>[1] 
<a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;3146771&#x2F;building-lisp-scheme-like-parse-tree-with-flex-bison#comment3234337_3146771" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;3146771&#x2F;building-lisp-sc...</a>
======
gus_massa
It's usually faster to submit it to the mailing list.

[spoiler alert]

The #s is brilliantly misleading. A shorter version is

    
    
      #x0#s0  ;==> 0.0f0 (almost like 0.0)
    

In this case, the second # means an unspecified digit in an inexact number.
For example

    
    
      4## ;==> 400.0 
    

(other scheme implementation may give a different result near 400, like 450.0)

The s is the exponent mark in a single precision number

    
    
      2s4 ;==> 20000.0f0

------
soegaard
First of all the `@` means we are dealing with a an inexact

    
    
        ‹inexact-complexn› ::= ‹inexact-realn› @ ‹inexact-realn›
    
    

Here is a short guide: #e means exact #x means hexadecimal

So `#e#x+e` means exact 14.

The last `#` in means an unknown number - Racket has chosen to use 0.
Therefore `#e#x+e#` means 14 _16 = 224.

The `s0` is an exponent mark, which marks the precision of an inexact number.
The `s0` means single-precision (in Scheme s means short - in many
implementations short and single both use single precision).

Thus `#x+e#s0` means `224.0f` and `#e#x+e#s0` means 224.

Now since it is a hexadecimal number the following `+e` means 14. Therefore
`#e#x+e#s0+e` means `224_16^14` which is 16140901064495857664.

Now we come the `@`. This means the first part was the real part of a complex
number and what follows is the imaginary part.

