Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Variable with float value is nil

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 451 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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).

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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 🙂

              1 Reply Last reply Reply Quote 0
              • First post
                Last post