Skip to content

Commit

Permalink
- Added support for initialization of numbers in different bases.
Browse files Browse the repository at this point in the history
Example:
	say Number("deadbeef", 16);		# hexadecimal
	say Number("666", 8);			# octal

This also fixes the conversion of strings to numbers, such as "012".to_i (will convert it into 12 in base 10)

- Updated the .pod files.
- Updated the .sf scripts.
  • Loading branch information
trizen committed Dec 26, 2015
1 parent 445a699 commit dec506c
Show file tree
Hide file tree
Showing 22 changed files with 465 additions and 1,597 deletions.
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ scripts/Applications/fdf.sf
'scripts/Applications/Gift match/input.txt'
'scripts/Applications/Gift match/output.txt'
scripts/Applications/make_filenames_safe.sf
scripts/Applications/smart-units.sf
scripts/bernoulli_numbers.sf
scripts/bernoulli_numbers_recursive.sf
scripts/caesar_cipher.sf
Expand Down
52 changes: 0 additions & 52 deletions lib/Sidef/Convert/Convert.pod
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ Aliases: I<to_bool>

=cut

=head2 to_byte

Convert.to_byte() -> I<Obj>

Return the

=cut

=head2 to_bytes

Convert.to_bytes() -> I<Obj>

Return the

=cut

=head2 to_c

Convert.to_c() -> I<Obj>
Expand All @@ -68,22 +52,6 @@ Return the

=cut

=head2 to_char

Convert.to_char() -> I<Obj>

Return the

=cut

=head2 to_chars

Convert.to_chars() -> I<Obj>

Return the

=cut

=head2 to_dir

Convert.to_dir() -> I<Obj>
Expand Down Expand Up @@ -118,26 +86,6 @@ Return the

=cut

=head2 to_graph

Convert.to_graph() -> I<Obj>

Return the

Aliases: I<to_grapheme>

=cut

=head2 to_graphs

Convert.to_graphs() -> I<Obj>

Return the

Aliases: I<to_graphemes>

=cut

=head2 to_i

Convert.to_i() -> I<Obj>
Expand Down
162 changes: 0 additions & 162 deletions lib/Sidef/Math/Math.pod
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ Inherits methods from:
=head1 METHODS


=head2 abs

Math.abs() -> I<Obj>

Return the

=cut

=head2 accuracy

Math.accuracy() -> I<Obj>

Return the

=cut

=head2 acos

Math.acos() -> I<Obj>
Expand Down Expand Up @@ -183,22 +167,6 @@ Return the

=cut

=head2 ceil

Math.ceil() -> I<Obj>

Return the

=cut

=head2 cos

Math.cos() -> I<Obj>

Return the

=cut

=head2 cosec

Math.cosec() -> I<Obj>
Expand Down Expand Up @@ -295,30 +263,6 @@ Return the

=cut

=head2 e

Math.e() -> I<Obj>

Return the

=cut

=head2 exp

Math.exp() -> I<Obj>

Return the

=cut

=head2 floor

Math.floor() -> I<Obj>

Return the

=cut

=head2 gcd

Math.gcd() -> I<Obj>
Expand Down Expand Up @@ -359,14 +303,6 @@ Return the

=cut

=head2 inf

Math.inf() -> I<Obj>

Return the

=cut

=head2 lcm

Math.lcm() -> I<Obj>
Expand All @@ -375,30 +311,6 @@ Return the

=cut

=head2 log

Math.log() -> I<Obj>

Return the

=cut

=head2 log10

Math.log10() -> I<Obj>

Return the

=cut

=head2 log2

Math.log2() -> I<Obj>

Return the

=cut

=head2 map

Math.map() -> I<Obj>
Expand Down Expand Up @@ -431,22 +343,6 @@ Return the

=cut

=head2 npow

Math.npow() -> I<Obj>

Return the

=cut

=head2 npow2

Math.npow2() -> I<Obj>

Return the

=cut

=head2 num2percent

Math.num2percent() -> I<Obj>
Expand All @@ -457,32 +353,6 @@ Aliases: I<number_to_percentage>

=cut

=head2 pi

Math.pi() -> I<Obj>

Return the

Aliases: I<PI>

=cut

=head2 pow

Math.pow() -> I<Obj>

Return the

=cut

=head2 precision

Math.precision() -> I<Obj>

Return the

=cut

=head2 rad2deg

Math.rad2deg() -> I<Obj>
Expand Down Expand Up @@ -523,14 +393,6 @@ Return the

=cut

=head2 root

Math.root() -> I<Obj>

Return the

=cut

=head2 sec

Math.sec() -> I<Obj>
Expand All @@ -547,14 +409,6 @@ Return the

=cut

=head2 sin

Math.sin() -> I<Obj>

Return the

=cut

=head2 sinh

Math.sinh() -> I<Obj>
Expand All @@ -563,14 +417,6 @@ Return the

=cut

=head2 sqrt

Math.sqrt() -> I<Obj>

Return the

=cut

=head2 sum

Math.sum() -> I<Obj>
Expand All @@ -594,11 +440,3 @@ Math.tanh() -> I<Obj>
Return the

=cut

=head2 troot

Math.troot() -> I<Obj>

Return the

=cut
2 changes: 1 addition & 1 deletion lib/Sidef/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ package Sidef::Parser {

# Binary, hexdecimal and octal numbers
if (/\G0(b[10_]*|x[0-9A-Fa-f_]*|[0-9_]+\b)/gc) {
return Sidef::Types::Number::Number->new("0" . ($1 =~ tr/_//dr));
return Sidef::Types::Number::Number->new("0" . ($1 =~ tr/_//dr), 0);
}

# Integer or float number
Expand Down
Loading

0 comments on commit dec506c

Please sign in to comment.