feat(lang): float and double types with ordinary operators

`float` (32-bit) and `double` (64-bit) with + - * / %, comparisons and unary minus.
Decimal literals take their type from context and stay `fixed` elsewhere; int and long
promote implicitly (LUDIC_WARN_FLOAT_PROMOTE=1 lists every promotion). float(), double(),
int(), long() and fixed() convert; floats(n)/doubles(n) buffers; float fields, globals,
constants and parameters; Math.* computes in float for float arguments; string/print
write the shortest round-tripping decimal; float_bits/float_from_bits expose the bits.
@deterministic code may not use floats. The f_* runtime helpers stay as they are.

Editors know the new type words; the JetBrains plugin is 1.5.0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-16 16:02:03 +03:00
parent f92d7f89c6
commit e010c2cecc
40 changed files with 67726 additions and 57272 deletions

View file

@ -136,8 +136,10 @@ function lex_at(src: pointer, first_line: int) -> void {
continue
}
var v = 0
let nstart = i
while i < n and char_is_digit(src[i]) { v = v * 10 + (src[i] - 48); i += 1 }
# a fractional part makes it a Q16.16 fixed literal
# a fractional part makes it a Q16.16 fixed literal (its text is kept: in a
# float context the literal is exactly that decimal instead)
if i < n and src[i] == '.' and char_is_digit(src[i + 1]) {
i += 1
# Accumulate only the first 4 fractional digits: `fnum << 16` must stay
@ -149,7 +151,7 @@ function lex_at(src: pointer, first_line: int) -> void {
i += 1
}
let bits = (v << 16) + ((fnum << 16) + (fden >> 1)) / fden
tok_push(TK_FLOAT, null, bits, line)
tok_push(TK_FLOAT, src[nstart..i], bits, line)
continue
}
tok_push(TK_INT, null, v, line)