fmax and fmin problems in Propeller C
ChrisL8
Posts: 129
Simple question, why won't this C code build in SimpleIDE?
This is the error I get:
If I change myNumber to a straight declaration like:
double myNumber = 3.5;
then it works fine.
If I don't try to pass newNumber to a function it also works fine.
What I am trying to do is take numbers coming in over the serial port,
convert them to doubles with strtod,
then compare them with existing numbers and pick the larger and smaller of the two,
and finally use these numbers in other functions.
It appears though that if I try to use fmin or fmax on a double that comes out of strtod I cannot use the output in any function without errors from the compiler.
If what I am trying is impossible, please feel free to offer other directions, such as:
C++?
Another format to pass data over the serial port besides strings?
Another way to get the smaller and larger of two floats besides fmin & fmax?
Thank you!
#include "simpletools.h" int main() { char *ptr; double myNumber = strtod("3.5", &ptr); double newNumber = fmin(myNumber, 2.5); print("%f\n", newNumber); }
This is the error I get:
propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2162) ... c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/cmm/short-doubles\libm.a(s_fmin.o): In function `_fmin': (.text+0x1e): undefined reference to `___signbit' c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/cmm/short-doubles\libm.a(s_fmin.o): In function `_fmin': (.text+0x26): undefined reference to `___signbit' c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/cmm/short-doubles\libm.a(s_fmin.o): In function `_fmin': (.text+0x30): undefined reference to `___signbit' collect2: ld returned 1 exit status Done. Build Failed! Check source for bad function call or global variable name __signbit' c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/cmm/short-doubles\libm.a(s_fmin.o): In function `_fmin': (.text+0x26)
If I change myNumber to a straight declaration like:
double myNumber = 3.5;
then it works fine.
If I don't try to pass newNumber to a function it also works fine.
What I am trying to do is take numbers coming in over the serial port,
convert them to doubles with strtod,
then compare them with existing numbers and pick the larger and smaller of the two,
and finally use these numbers in other functions.
It appears though that if I try to use fmin or fmax on a double that comes out of strtod I cannot use the output in any function without errors from the compiler.
If what I am trying is impossible, please feel free to offer other directions, such as:
C++?
Another format to pass data over the serial port besides strings?
Another way to get the smaller and larger of two floats besides fmin & fmax?
Thank you!
Comments
Just wanted to suggest the same solution
btw. the problem with fmin can I see also.