Community
cancel
Showing results for 
Search instead for 
Did you mean: 
122 Views

An error when converting from double to Ipp32f.

double value = 0;
Ipp32f pValD;
Ipp8u Buf[]="19970501";
value = atof((const char*)Buf);
pValD = (Ipp32f )value;

From debugger:
value19970501.000000000double
pValD19970500.float

the result in pValD=19970500 , not 19970501
this error occurs when converting from double to Ipp32f.


Do you have any explanation?

0 Kudos
7 Replies
Emmanuel_W_
New Contributor I
122 Views

Quoting - thstart

double value = 0;
Ipp32f pValD;
Ipp8u Buf[]="19970501";
value = atof((const char*)Buf);
pValD = (Ipp32f )value;

From debugger:
value19970501.000000000double
pValD19970500.float

the result in pValD=19970500 , not 19970501
this error occurs when converting from double to Ipp32f.


Do you have any explanation?

Ipp32f is a 32bit floating point, double are generally 64 bits thus have more precision and can represent bigger numbers.

Not all natural numbers can be represented by floating points. In your case there is probably no representation for 19970501 in 32 bits but there is in 64 bits (I didn't do the math but you can convinced yourself if you look online for the internal representation of floating point).

Hope this help,

Emmanuel

122 Views

Quoting - eweber

Ipp32f is a 32bit floating point, double are generally 64 bits thus have more precision and can represent bigger numbers.

Not all natural numbers can be represented by floating points. In your case there is probably no representation for 19970501 in 32 bits but there is in 64 bits (I didn't do the math but you can convinced yourself if you look online for the internal representation of floating point).

Hope this help,

Emmanuel

Yes you are right - flat has significant max 7 digits. The problem
is actually I need a fast conversion between string and Intel types.
In this case I have to use Microsoft's _atodbl. I am using vectors
and this would be a performance problem. Does Intel has a vector
string to Intel types conversion function?

Vladimir_Dudnik
Employee
122 Views

Hello,
'Intel types' is nothing more than just typedefs (see ippdefs.h file)
typedef float Ipp32f;
typedef double Ipp64f;
We do not have string to typeconversion functions in IPP.
Regards,
Vladimir

122 Views

Quoting - vdudnik
Hello,
'Intel types' is nothing more than just typedefs (see ippdefs.h file)
typedef float Ipp32f;
typedef double Ipp64f;
We do not have string to typeconversion functions in IPP.
Regards,
Vladimir

If they are just typedefs, how they are 32 bit aligned?

Vladimir_Dudnik
Employee
122 Views

What do you mean? How typedef is related to memory alignment?

122 Views

Quoting - vdudnik
What do you mean? How typedef is related to memory alignment?

I just want to use 32 bit memory alignment when for example create an array
and read from a disk file for example.

Vladimir_Dudnik
Employee
122 Views

You mayuse ippMalloc/ippFree functions which provide you 32-bytes aligned memory buffer (so 32-bit alignment is guaranteed for sure)
Vladimir

Reply