- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I noticed through the following that division by a number much larger than a 1000 doesn't work well unless it is broken into steps. Why is this the case? I assumed that this is something that would be done automatically..
pulselen = (Ch1Period - Channel_1_Count)/1000000;
sprintf(StringToPrint,"pulselen is %lf s \r\n",pulselen); ///DOESNT WORK-prints 0.000000
UART_1_PutString(StringToPrint);
pulselen = (Ch1Period - Channel_1_Count)/100;
pulselen = pulselen/100;
pulselen = pulselen/100;
sprintf(StringToPrint,"pulselen is %lf s \r\n",pulselen); ///WORKS
UART_1_PutString(StringToPrint);
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Replace /1000000 with /((float) 1000000) or /1000000.0 Compiler treats expression as integer and truncates fractional result to zero
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Replace /1000000 with /((float) 1000000) or /1000000.0 Compiler treats expression as integer and truncates fractional result to zero
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!