- Timestamp:
- Jun 22, 2021, 9:00:19 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/crt_abstractions.c
r457 r464 6 6 #include <stdlib.h> 7 7 #include <stdarg.h> 8 #include <stdint.h> 8 9 #include <string.h> 9 10 #include <limits.h> … … 598 599 case FST_NUMBER: 599 600 val = fraction * pow(10.0, (double)exponential) * (double)signal; 600 if ((val >= ( FLT_MAX * (-1.0f))) && (val <=FLT_MAX))601 if ((val >= ((double)FLT_MAX * (-1.0))) && (val <= (double)FLT_MAX)) 601 602 { 602 603 /*Codes_SRS_CRT_ABSTRACTIONS_21_016: [The strtof_s must return the float that represents the value in the initial part of the string. If any.]*/ … … 836 837 return result; 837 838 } 839 840 /*takes "value" and transforms it into a decimal string*/ 841 /*10 => "10"*/ 842 /*return 0 when everything went ok*/ 843 int uint64_tToString(char* destination, size_t destinationSize, uint64_t value) 844 { 845 int result; 846 size_t pos; 847 /*the below loop gets the number in reverse order*/ 848 if ( 849 (destination == NULL) || 850 (destinationSize < 2) /*because the smallest number is '0\0' which requires 2 characters*/ 851 ) 852 { 853 result = MU_FAILURE; 854 } 855 else 856 { 857 pos = 0; 858 do 859 { 860 destination[pos++] = '0' + (value % 10); 861 value /= 10; 862 } while ((value > 0) && (pos < (destinationSize - 1))); 863 864 if (value == 0) 865 { 866 size_t w; 867 destination[pos] = '\0'; 868 /*all converted and they fit*/ 869 for (w = 0; w <= (pos - 1) >> 1; w++) 870 { 871 char temp; 872 temp = destination[w]; 873 destination[w] = destination[pos - 1 - w]; 874 destination[pos - 1 - w] = temp; 875 } 876 result = 0; 877 } 878 else 879 { 880 result = MU_FAILURE; 881 } 882 } 883 return result; 884 }
Note:
See TracChangeset
for help on using the changeset viewer.