| 885 | |
| 886 | |
| 887 | static char* |
| 888 | icvFloatToString( char* buf, float value ) |
| 889 | { |
| 890 | Cv32suf val; |
| 891 | unsigned ieee754; |
| 892 | val.f = value; |
| 893 | ieee754 = val.u; |
| 894 | |
| 895 | if( (ieee754 & 0x7f800000) != 0x7f800000 ) |
| 896 | { |
| 897 | int ivalue = cvRound(value); |
| 898 | if( ivalue == value ) |
| 899 | sprintf( buf, "%d.", ivalue ); |
| 900 | else |
| 901 | { |
| 902 | static const char* fmt = "%.8e"; |
| 903 | char* ptr = buf; |
| 904 | sprintf( buf, fmt, value ); |
| 905 | if( *ptr == '+' || *ptr == '-' ) |
| 906 | ptr++; |
| 907 | for( ; cv_isdigit(*ptr); ptr++ ) |
| 908 | ; |
| 909 | if( *ptr == ',' ) |
| 910 | *ptr = '.'; |
| 911 | } |
| 912 | } |
| 913 | else |
| 914 | { |
| 915 | if( (ieee754 & 0x7fffffff) != 0x7f800000 ) |
| 916 | strcpy( buf, ".Nan" ); |
| 917 | else |
| 918 | strcpy( buf, (int)ieee754 < 0 ? "-.Inf" : ".Inf" ); |
| 919 | } |
| 920 | |
| 921 | return buf; |
| 922 | } |
| 923 | |
| 924 | |
| 925 | static void |
no test coverage detected