Variable with float value is nil



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

    On 31/01/2012 at 07:14, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   13 
    Platform:    Mac  ;  Mac OSX  ; 
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Try the following:

      
    main(doc,op)   
    {   
    var temp=10.0;   
    println(temp==nil);   
    }   
    

    I get a 1, saying that it is a nil.
    But if you modify the first line to:

      
    var temp=10;   
    

    It returns 0, saying it is not a nil.
    This is a bug, right?



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

    On 31/01/2012 at 07:20, xxxxxxxx wrote:

    I have a parsing function that parses for numbers, strings and variables. It works just fine except if it parses a floating point number. Because, when I try to check if it found a legitimate value (it is!!!) so that I could use it, with:

      
    if(value!=nil) ...   
    

    It returns me a nil because it can't see that it is a numerical floating point value.
    This is ruining my code that was previosly working just fine (in release 11.5).



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

    On 31/01/2012 at 14:10, xxxxxxxx wrote:

    Now it really looks like a bug.
    If I change the code to:

      
    main(doc,op)   
    {   
    var t=10.1;   
    println(t==nil);   
    }   
    

    It will print out 0, as expected.
    It is only when the float is equal to its integer (as in, 1.0 or 10.0 ou -2.0) that the test for nil returns true.



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

    On 31/01/2012 at 15:40, xxxxxxxx wrote:

    I can also confirm that nil doesn't seem to work when the decimal value is .0.

    Can you use this as an alternative to nil in your projects Rui?:

    main(doc,op)  
    {  
    var t=10.0;  
    if(t!=null)println(t);  
    }
    

    -ScottA



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

    On 31/01/2012 at 15:57, xxxxxxxx wrote:

    Yes, with null it seems to be working.
    Anyway, I already reported it to Maxon.
    Thank you, Scott :-)


Log in to reply