-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added the Number.base() method to return the self number in as a st…
…ring in a given base. Example: say 255.base(16); # prints: "ff" - Improved the Number.as_oct(), Number.as_bin() and Number.as_hex() methods to no longer use Math::BigInt for conversion. - Improved the String.bin(), String.oct() and String.hex() methods to support big integers.
- Loading branch information
trizen
committed
Dec 29, 2015
1 parent
b93392a
commit 33df118
Showing
6 changed files
with
36 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
# Answer: 100 | ||
|
||
var prod = 1.rat; | ||
var prod = 1; | ||
|
||
9.times { |i| | ||
9.times { |j| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
#!/usr/bin/ruby | ||
|
||
var dec = '0123459'; | ||
var hex_noprefix = 'abcf123'; | ||
var hex_withprefix = '0xabcf123'; | ||
var oct_noprefix = '7651'; | ||
var oct_withprefix = '07651'; | ||
var bin_noprefix = '101011001'; | ||
var bin_withprefix = '0b101011001'; | ||
var dec = '0123459'; | ||
var hex = 'abcf123'; | ||
var oct = '7651'; | ||
var bin = '101011001'; | ||
|
||
assert_eq( 123459, dec.num); | ||
assert_eq(180154659, hex_noprefix.hex); | ||
assert_eq(180154659, hex_withprefix.hex); | ||
assert_eq( 4009, oct_noprefix.oct); | ||
assert_eq( 4009, oct_withprefix.oct); | ||
assert_eq( 345, bin_noprefix.bin); | ||
assert_eq( 345, bin_withprefix.bin); | ||
assert_eq(180154659, hex.hex); | ||
assert_eq( 4009, oct.oct); | ||
assert_eq( 345, bin.bin); | ||
|
||
say "** Test passed!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters