pchapin / scala

Scalaness: A stagged programming system for embedded systems based on Scala.
0 stars 0 forks source link

The type of the literal -128 is incorrect #6

Open pchapin opened 11 years ago

pchapin commented 11 years ago

The specification of Mininess in the Scalaness User Documentation says that the negative sign when applied to an integer literal is part of the literal. That is '-128' is a single token and not the '-' token followed by the '128' token. This is important because otherwise -128 will have type int16_t rather than int8_t as it should. In particular '128' must have type int16_t since 128 is too large to represent with int8_t. With the '-' sign as part of the literal token the compiler can see that '-128' is a legal int8_t value and assign it an appropriate type.