## nasal math.pow() : power of float

Nasal is the scripting language of FlightGear.

### nasal math.pow() : power of float

Hi,
the nasal math.pow(x,y) where y is a float leads to an error:
Code: Select all
`Nasal runtime error: floating point error in math.pow()`

ref: https://sourceforge.net/p/flightgear/simgear/ci/next/tree/simgear/nasal/mathlib.c#l68

But the 'c' <math.h> pow functions are defined as:
Code: Select all
`double pow(double x, double y);float powf(float x, float y);long double powl(long double x, long double y);`

So, is there a way to get the same with Nasal where 'y' is rationnal or irrationnal ? (w/o defined my own powf ...)
Thanks,

Val.

[EDIT]
and with have the same with C++ <cmath> where pow is overloaded:
Code: Select all
`float pow(float base, int exp);float pow(float base, float exp);...`
vslash
Retired

Posts: 39
Joined: Fri May 27, 2016 9:43 pm
Location: Paris
Callsign: FGX412
IRC name: vslash
OS: BSD

### Re: nasal math.pow() : power of float

You must have done something wrong, I am using pow with 2 floating point numbers.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore

Necolatis

Posts: 2044
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

### Re: nasal math.pow() : power of float

Maybe it cannot handle negative exponent, if that's the case just use the absolute, and take the reciprocal of the final result. Will give same.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore

Necolatis

Posts: 2044
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

### Re: nasal math.pow() : power of float

pow(x,y) with x < 0 is not really the best way using pow ! (I was focused on y)
thanks,

Val.
vslash
Retired

Posts: 39
Joined: Fri May 27, 2016 9:43 pm
Location: Paris
Callsign: FGX412
IRC name: vslash
OS: BSD

### Who is online

Users browsing this forum: No registered users and 0 guests