mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-30 04:00:02 +02:00
[poincare] Ensure that a float power an integer in a real
Change-Id: I19416271f127ac487f61191cacc6243bb4e0c160
This commit is contained in:
@@ -47,6 +47,13 @@ Expression * Power::evaluateOnComplex(Complex * c, Complex * d, Context& context
|
||||
}
|
||||
/* Third case only c is complex */
|
||||
float radius = powf(c->r(), d->a());
|
||||
if (c->b() == 0 && d->a() == roundf(d->a())) {
|
||||
/* We handle the case -c float and d integer- separatly to avoid getting
|
||||
* complex result due to float representation: a float power an integer is
|
||||
* always real. */
|
||||
return new Complex(Complex::Cartesian(radius, 0.0f));
|
||||
}
|
||||
/* Third case only c is complex */
|
||||
float theta = d->a()*c->th();
|
||||
return new Complex(Complex::Polar(radius, theta));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user