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 conversions
2+
3+puts (-5).abs # 5
4+puts 3.14.to_i # 3
5+puts 3.14.ceil # 4
6+puts 3.14.floor # 3
7+puts 3.14.round # 3
8+puts 3.75.round # 4
9+
10+# Integer methods
11+puts 7.even? # false
12+puts 8.even? # true
13+puts 7.odd? # true
14+puts 10.zero? # false
15+puts 0.zero? # true
16+
17+# Numeric abs
18+puts (-3.14).abs # 3.14
19+
20+# Power
21+puts 2 ** 10 # 1024