Project

General

Profile

Actions

Bug #15015

open

Wrong result from cpow in libc

Added by Rikard Nordgren 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

The c program below gives the wrong result. The output is 0.000000, -4.624796 but it should be 0.000000, -0.216226 . I have compared the calculation with glibc on Linux and wolfram alpha online.

#include <stdio.h>
#include <complex.h>

int main()
{
    double complex base = 4.62479554547*I;
    double complex exp = -1.0;
    double complex res = cpow(base, exp);

    printf("%f, %f\n", creal(res), cimag(res)); 
    return 0;
}

I tested the code with gcc on OpenIndiana with the following output from uname -a : SunOS openindiana 5.11 illumos-4f9241761d i86pc i386 i86pc

No data to display

Actions

Also available in: Atom PDF