Project

General

Profile

Feature #10255 ยป math.c_ Math.log with base 0 or 1 should raise DomainError.PATCH

gogotanaka (Kazuki Tanaka), 09/18/2014 05:51 AM

View differences:

math.c
459 459
math_log(int argc, const VALUE *argv, VALUE obj)
460 460
{
461 461
    VALUE x, base;
462
    double d;
462
    double d0, d;
463 463
    rb_scan_args(argc, argv, "11", &x, &base);
464 464
    d = math_log1(x);
465 465
    if (argc == 2) {
466
        Need_Float(base);
467
        d0 = RFLOAT_VALUE(base);
468
        if (d0 == 0.0 || d0 == 1.0) domain_error("log");
466 469
        d /= math_log1(base);
467 470
    }
468 471
    return DBL2NUM(d);