PC specific SDK Bug?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 20/07/2009 at 18:09, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9+ 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Howdy,

    I think there is a bug in the PC version of the SDK, specifically dealing with the Len() function.

    If you use this code on the PC:

    > Bool TestCommand::Execute(BaseDocument\* doc) \> { \>      Vector a = Vector(46,46,46), b = Vector(0,0,0); \>      Real length = Len(a-b); \>       \>      if(Len(a-b) < length) GePrint("TRUE"); \>       \>      return TRUE; \> }

    On the PC, the console will print TRUE, but clearly that's wrong because the values should be equal. On the Mac, the console prints nothing, as it should be. This bug is present on the PC in R9, R10 and R11.

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 20/07/2009 at 23:45, xxxxxxxx wrote:

    Hi Cactus,

    by the way, comparing floats with the == operator is not recommended. Take a look at this: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

    Yes I know, its a big topic but sometimes its goot to know.

    Bye, Shawni



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/07/2009 at 06:04, xxxxxxxx wrote:

    Rule of thumb, don´t call a function as an if condition. ;-)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/07/2009 at 06:12, xxxxxxxx wrote:

    Howdy,

    Yes, I understand that about floating point imprecision.

    But the odd thing about the comparison is that if the previously posted code is changed to this:

    > Bool TestCommand::Execute(BaseDocument\* doc) \> { \>      Vector a = Vector(46,46,46), b = Vector(0,0,0); \>      Real length = Len(a-b); \>       \>      Real vLen = Len(a-b); \>      if(vLen < length) GePrint("TRUE"); \>       \>      return TRUE; \> }

    Then it works on both Mac and PC.

    So, I've gone through all of my code looking for the Len() function and if it's used in an if() statement, add a Real storage variable just before the if() statement and compare the two variables instead. ;o)

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/07/2009 at 06:13, xxxxxxxx wrote:

    Howdy,

    > Quote: Originally posted by 3D Designer on 21 July 2009
    >
    > * * *
    >
    > Rule of thumb, don´t call a function as an if condition. ;-)
    >
    >
    > * * *

    Yes, it seems that is the case here. ;o)

    Adios,
    Cactus Dan


Log in to reply