There are two ways to represent float in nesc.

One way, is to do it through by convention using the exponent and mantissa,

where you need to use 2^exponent. The function that does that is called powf().

The problem with using that function is that it is reaaaaallly slow.

[QUOTE]

----8<---- span="">

DbgOut_P20_ON;

r = logf((float)v / 10000.0); // takes up about 10 ms (!!)

DbgOut_P20_OFF;

----8<---- span="">

and a

----8<---- span="">

DbgOut_P20_ON;

r =

DbgOut_P20_OFF;

----8<---- span="">

[/QUOTE]

In case you need to have fast response, this function might not be your choice.

One way to optimize the speed of those operations are:

"I'd like to mention that

exp(b). Use the latter whenever possible.

fixed, use exp(b * log(a)) rather than

common low-precision implementation technique even when a is not fixed.)

Also note that keeping logarithms

convenient, and shaves a bit of overhead from the code when you

don't have hardware floating-point. "

One quite dirty trick to show real numbers in nesc is to define fix point.

for example in 16 bits, you say 12 bits are the bits before the decimal point, and 4 bits are bits after the point. a(12bits) + ( b(4bits)/16 ).

This dirty trick is good in case one wants working with float go faster, without need for much precision.

One way, is to do it through by convention using the exponent and mantissa,

where you need to use 2^exponent. The function that does that is called powf().

The problem with using that function is that it is reaaaaallly slow.

[QUOTE]

----8<---- span="">

DbgOut_P20_ON;

r = logf((float)v / 10000.0); // takes up about 10 ms (!!)

DbgOut_P20_OFF;

----8<---- span="">

and a

----8<---- span="">

DbgOut_P20_ON;

r =

**powf**(10,(float)v / 10000.0); // takes up about 32 ms (!!!!!!)DbgOut_P20_OFF;

----8<---- span="">

[/QUOTE]

In case you need to have fast response, this function might not be your choice.

One way to optimize the speed of those operations are:

"I'd like to mention that

**pow**(a,b) is MUCH harder to implement thanexp(b). Use the latter whenever possible.

**In**particular, if a isfixed, use exp(b * log(a)) rather than

**pow**(a,b). (**In**fact, that's acommon low-precision implementation technique even when a is not fixed.)

Also note that keeping logarithms

**in**fixed-point format is oftenconvenient, and shaves a bit of overhead from the code when you

don't have hardware floating-point. "

One quite dirty trick to show real numbers in nesc is to define fix point.

for example in 16 bits, you say 12 bits are the bits before the decimal point, and 4 bits are bits after the point. a(12bits) + ( b(4bits)/16 ).

This dirty trick is good in case one wants working with float go faster, without need for much precision.