Commit 97d872e7
97d872e765f9Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified
Description
Add numeric methods, Float puts, Integer#**
New features:
- Integer#abs, #even?, #odd?, #zero?
- Integer#** (power via pow())
- Float#abs (fabs), #ceil, #floor, #round
- puts with Float → printf("%g")
Test: examples/bm_numeric.rb — all patterns match Ruby.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 97d872e765f9
- Parent
- 03933eb9bb2b
examples/bm_numeric.rbaddedView file
1+
# Test numeric methods and conversions2+
3+
puts (-5).abs # 54+
puts 3.14.to_i # 35+
puts 3.14.ceil # 46+
puts 3.14.floor # 37+
puts 3.14.round # 38+
puts 3.75.round # 49+
10+
# Integer methods11+
puts 7.even? # false12+
puts 8.even? # true13+
puts 7.odd? # true14+
puts 10.zero? # false15+
puts 0.zero? # true16+
17+
# Numeric abs18+
puts (-3.14).abs # 3.1419+
20+
# Power21+
puts 2 ** 10 # 1024src/codegen.cmodifiedView file
Loading diff…