MCPcopy Create free account
hub / github.com/creatale/node-dv / icvFloatToString

Function icvFloatToString

deps/opencv/modules/core/src/persistence.cpp:887–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885
886
887static char*
888icvFloatToString( 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
925static void

Callers 1

cvWriteRawDataFunction · 0.85

Calls 2

cvRoundFunction · 0.85
cv_isdigitFunction · 0.85

Tested by

no test coverage detected