Jump to content

[SOLVED] long in uniginescript == long long in c++?


photo

Recommended Posts

Posted

it seems the long type in uniginescript should be equal to long long type in c++.

 

long x=pow(2,32);‏

 
log.message("%016lx\n",x); //wrong 

 

log.message("%016llx\n",x); //correct

Posted

After i play around with long type in uniginescript. i found the following issue

1:assign issue. 

if i assign long this way (same as 0x4000000000000000)

long mask=4611686018427387904; 
log.message("mask:%016llx\n",mask); 

result:the print value is 0

the only way to assign long is 

 long mask=long("0x4000000000000000"); 

2:if issue:

with above code

if(mask & (1l << 62))) will always be skipped even the result is not 0

way to use if

if((mask & (1l << 62))!=0)

are those behavior correct?

Posted

Hello,

  • You should add "L" or "l" to your number. For example: long mask = 4611686018427387904L;
  • if((mask & (1l << 62)) !=0) is correct way to check the results of bitwise and operator if you are using long. Also, you can use more strict check:

    	long mask =  long("0x710fffffffffffff");
    	long check = long("0x0100000000000000");
    	
    	if(check != 0 && (mask & check) == check) {
               //not skipped
            }

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...