Commit 449565ed
449565ed5cceMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Add Integer#[] bit access and Float#round(neg ndigits)
n[i] -> (n >> i) & 1 (Integer bit access). round/ceil/floor/truncate with a negative ndigits rounds to a power of ten left of the decimal, returning an Integer (1234.5.round(-1) == 1230).
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 449565ed5cce
- Parent
- 970dbc43105e
src/analyze.cmodifiedView file
@@ -293,6 +293,7 @@
293293
/* integer receiver methods */294294
if (recv >= 0 && rt == TY_INT) {295295
if (!strcmp(name, "chr")) return TY_STRING;296+
if (!strcmp(name, "[]") && argc == 1) return TY_INT; /* bit access */296297
if (!strcmp(name, "gcd") || !strcmp(name, "lcm") || !strcmp(name, "clamp")) return TY_INT;297298
if (!strcmp(name, "digits")) return TY_INT_ARRAY;298299
if (!strcmp(name, "to_s") && argc == 1) return TY_STRING;src/codegen.cmodifiedView file
Loading diff…