[ODE] SOLVED Wrong brackets in definition of dSqrt in common.h ?

Rodrigo Hernandez kwizatz at aeongames.com
Wed Dec 14 16:46:54 MST 2005


Ok, I checked, The only warnings from MSVC++ were from the definition of 
the dDISTANCE function, so I fixed that,
I removed the castings because I dont see why would the single functions 
be any different on AMD64.

Now, if you (speaking in general) get the posible loss of data in 
conversion from double to float warning in your own code, change your 
explicit values to the ODE casting REAL(x)
or use (dReal) In Example:

dSqrt(REAL(2.0));

or

dSqrt((dReal)2.0);

Happy Coding!

Rodrigo Hernandez wrote:

>Jon Watte (ODE) wrote:
>
>  
>
>>Answering more than one message here:
>>
>>    
>>
>>>I noticed that all the macros use the float (not double) versions of 
>>>the functions (IE: sqrtf as opposed to sqrt) those of us still on 32 
>>>bit machines
>>>would not be affected by just removing the casts, so before I just 
>>>remove them... is there a reason for those casts to be there? It 
>>>seems to me that they're rather redundant.
>>>      
>>>
>>I beleive they remove warnings from the MSVC 7.1 compiler. Especially 
>>when passing in literals (like 2.0), that compiler is really anal.
>>
>>    
>>
>That may be the cause :-) I'll have to check.
>
>  
>
>>>:-)  Are you saying I'm awkward and it's my fault because I use a C
>>>compiler to compile C ?  ROTFL
>>>      
>>>
>>It's not clear to me that dSqrt() is an officially exported function 
>>that's intended to be part of the "C" API. However, if it is, then 
>>yes, the cast needs to be made right. (In fact, even if it isn't, just 
>>fixing the cast ought to be done)
>>
>>    
>>
>Well, "exported" is too big of a word, its defined in the common.h 
>header as a macro, and the header is part of the instalation
>
>  
>
>>The right definition should be sqrtf() for the dSINGLE version and 
>>sqrt() for the DOUBLE version, if they aren't already, btw.
>>
>>    
>>
>Thats exactly what they are, which is why I find (float)sqrtf(float(x)) 
>to be redundant, in any case, if we are to just avoid warnings the 
>correct definition should be just sqrtf( (float) x )
>
>  
>
>>Cheers,
>>
>>             / h+
>>
>>    
>>
>Cheers!
>_______________________________________________
>ODE mailing list
>ODE at q12.org
>http://q12.org/mailman/listinfo/ode
>
>  
>



More information about the ODE mailing list