Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up the Cool versions of the standard Numeric and Real methods.
  • Loading branch information
colomon committed Jun 8, 2010
1 parent b497776 commit 0290298
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions src/core/Cool-num.pm
Expand Up @@ -3,65 +3,72 @@ augment class Cool {
pir::set__NP(self);
}

method abs() {
(+self).abs;
method abs($x:) {
(+$x).abs;
}

method sign() {
self.defined ?? (+self).sign !! Mu;
method exp($x: $base = e) {
(+$x).exp(+$base);
}

multi method exp() {
self.Num.exp;
method log($x: $base = e) {
(+$x).log(+$base);
}

our Int multi method ceiling() is export {
self.Num.ceiling;
method log10($x:) {
(+$x).log10;
}

our Int multi method floor() is export {
self.Num.floor;
method sqrt($x:) {
(+$x).sqrt;
}

our Int multi method truncate() is export {
self.Num.truncate;
method roots($x: $n) {
(+$x).roots((+$n).Int);
}

our Int multi method round() is export {
self.Num.round;
method to-radians($x: $base) {
(+$x).to-radians($base);
}

our Str multi method chr() {
~(pir::chr__SI(self))
method from-radians($x: $base) {
(+$x).from-radians($base);
}

# TODO: Probably should be little or no mention of .Num in Any
our ::Complex multi method unpolar($angle) {
self.Num.unpolar($angle);
method floor($x:) {
(+$x).floor;
}

multi method cis() {
self.Num.cis
method ceiling($x:) {
(+$x).ceiling;
}

our Num method rand() {
pir::box__PN(pir::rand__NN(self))
method round($x: $scale = 1) is export {
(+$x).round(+$scale);
}

multi method roots($n) {
$.Complex.roots($n);
method truncate($x:) {
(+$x).truncate;
}

method sqrt($x:) {
(+$x).sqrt;
method sign($x:) {
$x.defined ?? (+$x).sign !! Mu;
}

multi method log($x: $base = e) {
(+$x).log(+$base);
method cis($angle:) {
(+$angle).cis
}

method unpolar($mag: $angle) {
(+$mag).unpolar(+$angle);
}

multi method log10() {
$.Num.log10;
our Str multi method chr() {
~(pir::chr__SI(self))
}

our Num method rand() {
pir::box__PN(pir::rand__NN(self))
}

method sin($x: $base = Radians) {
Expand Down

0 comments on commit 0290298

Please sign in to comment.