URL: <http://savannah.nongnu.org/bugs/?29458>
Summary: log10 compile errors Project: AVR C Runtime Library Submitted by: simconl Submitted on: Wed Apr 7 06:16:41 2010 Category: Library Severity: 3 - Normal Priority: 5 - Normal Item Group: libc code Status: None Percent Complete: 0% Assigned to: None Open/Closed: Open Discussion Lock: Any Release: Unknown Fixed Release: None _______________________________________________________ Details: Hello, Using the folowing code results to compile/link errors: #include <math.h> /*************************************************************** Project: SHTxx ***************************************************************/ typedef union { unsigned int i; float f; } value; //-------------------------------------------------------------- // calculates dew point // input:humidity [%RH], temperature [] // output: dew point //-------------------------------------------------------------- float calc_dewpoint(float h, float t) { float logEx; float dew_point; /**/ // Original code (ERROR!!!): logEx = 0.66077 + 7.5 * t / (237.3 + t) + (log10(h) - 2); dew_point = (logEx - 0.66077) * 237.3 / (0.66077 + 7.5 - logEx); /**/ /* // Modified code (just for the test): logEx = 0.66077 + 7.5 * t / (237.3 + t) + (1.0 - 2); dew_point = (logEx - 0.66077) * 237.3 / (0.66077 + 7.5 - logEx); */ return dew_point; } //-------------------------------------------------------------- // sample program that shows how to use SHT11 functions //-------------------------------------------------------------- int main(void) { value humi_val; value temp_val; float dew_point; while (1) { //converts integer to float humi_val.f = (float)humi_val.i; temp_val.f = (float)temp_val.i; //calculate dew point dew_point = calc_dewpoint(humi_val.f, temp_val.f); } return 0; } I'm using the WinAVR20100110 compiler, but the WinAVR20090313 has the same problem. I also use Studio4 4.18 SP2 build 700. The used micro is a ATXmega128A1. See function calc_dewpoint(). When I compile with the original code, it results in an compile error, so I modified the code and replaced the log10(h) code into 1.0. Now it is compiled without any errors. Hope this problem will be fixed soon. Regards, Robert. _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Wed Apr 7 06:16:41 2010 Name: FloatTest_20100406c.zip Size: 10kB By: simconl <http://savannah.nongnu.org/bugs/download.php?file_id=20144> ------------------------------------------------------- Date: Wed Apr 7 06:16:41 2010 Name: WinAvrBug.JPG Size: 215kB By: simconl <http://savannah.nongnu.org/bugs/download.php?file_id=20145> _______________________________________________________ Reply to this item at: <http://savannah.nongnu.org/bugs/?29458> _______________________________________________ Message sent via/by Savannah http://savannah.nongnu.org/ _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-libc-dev