SQLite Forum

document nit chapter 2 section 3 literals
Login
It turns out all kinds of weirdness ensues if you try to do negatives with lexemes.  This "beast" becomes hard to parse
```
5-3
```
because it lexes as two numbers...

The easiest thing to do is to treat negative numbers as positives with unary negation and repair that tree rapidly in the parser.  So you end up with something like a constant folded integer in the stream which is indistinguishable from an integer literal anyway.

However, there's a glitch.  You can represent -9223372036854775808 but you can't represent the +9223372036854775808 you need to negate... so you have to do... something... so that you don't overflow before you negate.  There's a bunch of ways to do this.

None of this belongs in the document :D

You could take the position in the documents that the system behaves as though numeric literals could be negative and call it good.  I wouldn't blame you... the details above make interesting trivia but poor documentation.