Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use explicit Num literals in Num.pm; nqp-jvm is more picky about nati…

…ve type coercions like nqp::add_n($x,1)
  • Loading branch information...
commit e60cfbe69e21d69664a59b261da06d00cc2441bc 1 parent 9599fcb
Stefan O'Rear sorear authored

Showing 1 changed file with 23 additions and 23 deletions. Show diff stats Hide diff stats

  1. +23 23 src/core/Num.pm
46 src/core/Num.pm
@@ -151,16 +151,16 @@ my class Num does Real {
151 151 nqp::p6box_n(nqp::asec_n(nqp::unbox_n(self)));
152 152 }
153 153 method cosec(Num:D:) {
154   - nqp::p6box_n(nqp::div_n(1, nqp::sin_n(nqp::unbox_n(self))));
  154 + nqp::p6box_n(nqp::div_n(1e0, nqp::sin_n(nqp::unbox_n(self))));
155 155 }
156 156 method acosec(Num:D:) {
157   - nqp::p6box_n(nqp::asin_n(nqp::div_n(1, nqp::unbox_n(self))));
  157 + nqp::p6box_n(nqp::asin_n(nqp::div_n(1e0, nqp::unbox_n(self))));
158 158 }
159 159 method cotan(Num:D:) {
160   - nqp::p6box_n(nqp::div_n(1, nqp::tan_n(nqp::unbox_n(self))));
  160 + nqp::p6box_n(nqp::div_n(1e0, nqp::tan_n(nqp::unbox_n(self))));
161 161 }
162 162 method acotan(Num:D:) {
163   - nqp::p6box_n(nqp::atan_n(nqp::div_n(1, nqp::unbox_n(self))));
  163 + nqp::p6box_n(nqp::atan_n(nqp::div_n(1e0, nqp::unbox_n(self))));
164 164 }
165 165 proto method sinh(|) {*}
166 166 multi method sinh(Num:D: ) {
@@ -168,7 +168,7 @@ my class Num does Real {
168 168 }
169 169 proto method asinh(|) {*}
170 170 multi method asinh(Num:D: ) {
171   - (self + (self * self + 1).sqrt).log;
  171 + (self + (self * self + 1e0).sqrt).log;
172 172 }
173 173 proto method cosh(|) {*}
174 174 multi method cosh(Num:D: ) {
@@ -176,7 +176,7 @@ my class Num does Real {
176 176 }
177 177 proto method acosh(|) {*}
178 178 multi method acosh(Num:D: ) {
179   - (self + (self * self - 1).sqrt).log;
  179 + (self + (self * self - 1e0).sqrt).log;
180 180 }
181 181 proto method tanh(|) {*}
182 182 multi method tanh(Num:D: ) {
@@ -184,7 +184,7 @@ my class Num does Real {
184 184 }
185 185 proto method atanh(|) {*}
186 186 multi method atanh(Num:D: ) {
187   - ((1 + self) / (1 - self)).log / 2;
  187 + ((1e0 + self) / (1e0 - self)).log / 2e0;
188 188 }
189 189 proto method sech(|) {*}
190 190 multi method sech(Num:D: ) {
@@ -192,23 +192,23 @@ my class Num does Real {
192 192 }
193 193 proto method asech(|) {*}
194 194 multi method asech(Num:D: ) {
195   - (1 / self).acosh;
  195 + (1e0 / self).acosh;
196 196 }
197 197 proto method cosech(|) {*}
198 198 multi method cosech(Num:D: ) {
199   - nqp::p6box_n(nqp::div_n(1, nqp::sinh_n(nqp::unbox_n(self))));
  199 + nqp::p6box_n(nqp::div_n(1e0, nqp::sinh_n(nqp::unbox_n(self))));
200 200 }
201 201 proto method acosech(|) {*}
202 202 multi method acosech(Num:D: ) {
203   - (1 / self).asinh;
  203 + (1e0 / self).asinh;
204 204 }
205 205 proto method cotanh(|) {*}
206 206 multi method cotanh(Num:D: ) {
207   - nqp::p6box_n(nqp::div_n(1, nqp::tanh_n(nqp::unbox_n(self))));
  207 + nqp::p6box_n(nqp::div_n(1e0, nqp::tanh_n(nqp::unbox_n(self))));
208 208 }
209 209 proto method acotanh(|) {*}
210 210 multi method acotanh(Num:D: ) {
211   - (1 / self).atanh;
  211 + (1e0 / self).atanh;
212 212 }
213 213 }
214 214
@@ -216,20 +216,20 @@ my constant pi = 3.14159_26535_89793_238e0;
216 216 my constant e = 2.71828_18284_59045_235e0;
217 217
218 218 multi prefix:<++>(Num:D \a is rw) { # XXX
219   - a = nqp::p6box_n(nqp::add_n(nqp::unbox_n(a), 1))
  219 + a = nqp::p6box_n(nqp::add_n(nqp::unbox_n(a), 1e0))
220 220 }
221 221 multi prefix:<++>(Num:U \a is rw) { # XXX
222 222 a = 1e0;
223 223 }
224 224 multi prefix:<-->(Num:D \a is rw) { # XXX
225   - a = nqp::p6box_n(nqp::sub_n(nqp::unbox_n(a), 1))
  225 + a = nqp::p6box_n(nqp::sub_n(nqp::unbox_n(a), 1e0))
226 226 }
227 227 multi prefix:<-->(Num:U \a is rw) { # XXX
228 228 a = -1e0;
229 229 }
230 230 multi postfix:<++>(Num:D \a is rw) { # XXX
231 231 my $b = a;
232   - a = nqp::p6box_n(nqp::add_n(nqp::unbox_n(a), 1));
  232 + a = nqp::p6box_n(nqp::add_n(nqp::unbox_n(a), 1e0));
233 233 $b
234 234 }
235 235 multi postfix:<++>(Num:U \a is rw) { # XXX
@@ -238,12 +238,12 @@ multi postfix:<++>(Num:U \a is rw) { # XXX
238 238 }
239 239 multi postfix:<-->(Num:D \a is rw) { # XXX
240 240 my $b = a;
241   - a = nqp::p6box_n(nqp::sub_n(nqp::unbox_n(a), 1));
  241 + a = nqp::p6box_n(nqp::sub_n(nqp::unbox_n(a), 1e0));
242 242 $b
243 243 }
244 244 multi postfix:<-->(Num:U \a is rw) { # XXX
245 245 a = -1e0;
246   - 0
  246 + 0e0
247 247 }
248 248
249 249 multi prefix:<->(Num:D \a) {
@@ -364,7 +364,7 @@ multi infix:«>=»(num $a, num $b) returns Bool:D {
364 364 }
365 365
366 366 sub rand() returns Num:D {
367   - nqp::p6box_n(nqp::rand_n(1));
  367 + nqp::p6box_n(nqp::rand_n(1e0));
368 368 }
369 369
370 370 # TODO: default seed of 'time'
@@ -377,10 +377,10 @@ multi sub atan2(Num:D $a, Num:D $b = 1e0) {
377 377 }
378 378
379 379 multi sub cosec(Num:D \x) {
380   - nqp::p6box_n(nqp::div_n(1, nqp::sin_n(nqp::unbox_n(x))));
  380 + nqp::p6box_n(nqp::div_n(1e0, nqp::sin_n(nqp::unbox_n(x))));
381 381 }
382 382 multi sub acosec(Num:D \x) {
383   - nqp::p6box_n(nqp::asin_n(nqp::div_n(1, nqp::unbox_n(x))));
  383 + nqp::p6box_n(nqp::asin_n(nqp::div_n(1e0, nqp::unbox_n(x))));
384 384 }
385 385
386 386 multi sub log(num $x) {
@@ -413,10 +413,10 @@ multi sub asec(num $x) {
413 413 }
414 414
415 415 multi sub cotan(num $x) {
416   - nqp::div_n(1, nqp::tan_n($x));
  416 + nqp::div_n(1e0, nqp::tan_n($x));
417 417 }
418 418 multi sub acotan(num $x) {
419   - nqp::div_n(1, nqp::atan_n($x));
  419 + nqp::div_n(1e0, nqp::atan_n($x));
420 420 }
421 421 multi sub sinh(num $x) {
422 422 nqp::sinh_n($x);
@@ -435,7 +435,7 @@ multi sub tanh(num $x) {
435 435 nqp::tanh_n($x);
436 436 }
437 437 multi sub atanh(num $x) {
438   - log((1 + $x) / (1 - $x)) / 2e0;
  438 + log((1e0 + $x) / (1e0 - $x)) / 2e0;
439 439 }
440 440 multi sub sech(num $x) {
441 441 nqp::sech_n($x);

0 comments on commit e60cfbe

Please sign in to comment.
Something went wrong with that request. Please try again.