float returns altered... though in range



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

    On 12/06/2009 at 12:46, xxxxxxxx wrote:

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

    ---------
        Hi,
       I'm translating a timer that returns the date in seconds from a consistent start time 70 years ago. It creates a 10 digit number. I tack on a few more digits for my product key manipulation.
       Problem is, the values I get back are inconsistent. I understand that an integer has a range limit below my number, but even when I convert everything to floats, I run into problems after 12 digits. I've duplicated the problem in this simple COFFEE expression.
    Any ideas?
    Thanks,
    Graham

    > main(doc,op) \> { \> var vNum = 01034121024.0; // This float prints OK on next lines \> println("vNum = ", vNum); \> println("int(vNum = ", int(vNum) ); \> println("float(vNum) = ", float(vNum) ); \> println(" "); \> \> var vNum = 010341210240.0; // This float prints incorrectly on next lines \> println("vNum = ", vNum); \> println("int(vNum = ", int(vNum) ); \> println("float(vNum) = ", float(vNum) ); \> println(" "); \> \> var vNum = 01034121024; // This integer prints incorrectly (may \>                          //be over 2,147,483,648 integer limit even \>                          //though it starts with a zero... still 11 digits) \> println("vNum = ", vNum); \> println("int(vNum = ", int(vNum/100) ); \> println("float(vNum) = ", float(vNum/100) ); \> println(3.4E38); // Float limit seems OK \> println(2147483649); // This laps to (-) by two since int limit is ...648 \> println(2147483647); // This int, at limit, prints this number as expected \> \> println("-------------------------------------------------------"); \> }



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

    On 13/06/2009 at 13:39, xxxxxxxx wrote:

    Do it as a string. Numbers in computer format can't start with a '0' (except for number smaller than 1 (0.xxxx) in floating point).


Log in to reply