believe or not it work on win32 but now for win32 and win64 I am using

int = float + 0.5

and it is also working


--- Em seg, 23/5/11, Ruben Van Boxem <vanboxem.ruben@gmail.com> escreveu:

De: Ruben Van Boxem <vanboxem.ruben@gmail.com>
Assunto: Re: [Mingw-w64-public] enhancements on the win32 to win64 conversion
Para: mingw-w64-public@lists.sourceforge.net
Data: Segunda-feira, 23 de Maio de 2011, 10:47

2011/5/23 RSPsoftware <arabcoder@yahoo.com.br>
the compiler dont show a warning about the win32 to win64 conversion in the following function, it would be great if the compiler report at least a warning about it

this function fail miserably in win64, and I have only detected it after the compilation and tests  

int
round_trick (float floatvalue_to_round)
{

float floattmp;
int rounded_value;

floattmp = (int) 0x00FD8000L + (floatvalue_to_round);
rounded_value = *(int *) (&floattmp) - (int) 0x4B7D8000L;

if (rounded_value != (short) rounded_value)
rounded_value = (rounded_value >> 31) ^ 0x7FFF;
return rounded_value ;
}

I am unable to decipher your function's inner workings, but I'm sure you will be better off with any of the answers to this question here:
http://stackoverflow.com/questions/485525/round-for-float-in-c

As to what goes wrong: probably the algorithm's assumptions on pointer size, in the line where you assign "rounded_value" for the first time. Also all the magic numbers look very fishy to me.

Ruben
 

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public



-----Anexo incorporado-----

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay

-----Anexo incorporado-----

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public