Ignore:
Timestamp:
Dec 23, 2011, 3:43:32 AM (9 years ago)
Author:
sam
Message:

core: fix the sign of a negative real number raised to an even power, and
add the corresponding unit test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/real.cpp

    r1115 r1116  
    693693    else /* x < 0 */
    694694    {
     695        /* Odd integer exponent */
     696        if (y == (round(y >> 1) << 1))
     697            return exp(y * log(-x));
     698
     699        /* Even integer exponent */
    695700        if (y == round(y))
    696701            return -exp(y * log(-x));
     702
    697703        /* FIXME: negative nth root */
    698704        return real::R_0;
Note: See TracChangeset for help on using the changeset viewer.