Variant INT and REAL are now 64 bits (other types remain at 32)
This commit is contained in:
@ -1547,20 +1547,20 @@ String::String(const StrRange& p_range) {
|
||||
|
||||
int String::hex_to_int(bool p_with_prefix) const {
|
||||
|
||||
int l = length();
|
||||
int l = length();
|
||||
if (p_with_prefix && l<3)
|
||||
return 0;
|
||||
|
||||
const CharType *s=ptr();
|
||||
const CharType *s=ptr();
|
||||
|
||||
int sign = s[0]=='-' ? -1 : 1;
|
||||
int sign = s[0]=='-' ? -1 : 1;
|
||||
|
||||
if (sign<0) {
|
||||
s++;
|
||||
l--;
|
||||
if (sign<0) {
|
||||
s++;
|
||||
l--;
|
||||
if (p_with_prefix && l<2)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p_with_prefix) {
|
||||
if (s[0]!='0' || s[1]!='x')
|
||||
@ -1569,26 +1569,74 @@ int String::hex_to_int(bool p_with_prefix) const {
|
||||
l-=2;
|
||||
};
|
||||
|
||||
int hex=0;
|
||||
int hex=0;
|
||||
|
||||
while(*s) {
|
||||
while(*s) {
|
||||
|
||||
CharType c = LOWERCASE(*s);
|
||||
int n;
|
||||
if (c>='0' && c<='9') {
|
||||
n=c-'0';
|
||||
} else if (c>='a' && c<='f') {
|
||||
n=(c-'a')+10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
CharType c = LOWERCASE(*s);
|
||||
int n;
|
||||
if (c>='0' && c<='9') {
|
||||
n=c-'0';
|
||||
} else if (c>='a' && c<='f') {
|
||||
n=(c-'a')+10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
hex*=16;
|
||||
hex+=n;
|
||||
s++;
|
||||
}
|
||||
hex*=16;
|
||||
hex+=n;
|
||||
s++;
|
||||
}
|
||||
|
||||
return hex*sign;
|
||||
return hex*sign;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int64_t String::hex_to_int64(bool p_with_prefix) const {
|
||||
|
||||
int l = length();
|
||||
if (p_with_prefix && l<3)
|
||||
return 0;
|
||||
|
||||
const CharType *s=ptr();
|
||||
|
||||
int64_t sign = s[0]=='-' ? -1 : 1;
|
||||
|
||||
if (sign<0) {
|
||||
s++;
|
||||
l--;
|
||||
if (p_with_prefix && l<2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p_with_prefix) {
|
||||
if (s[0]!='0' || s[1]!='x')
|
||||
return 0;
|
||||
s+=2;
|
||||
l-=2;
|
||||
};
|
||||
|
||||
int64_t hex=0;
|
||||
|
||||
while(*s) {
|
||||
|
||||
CharType c = LOWERCASE(*s);
|
||||
int64_t n;
|
||||
if (c>='0' && c<='9') {
|
||||
n=c-'0';
|
||||
} else if (c>='a' && c<='f') {
|
||||
n=(c-'a')+10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
hex*=16;
|
||||
hex+=n;
|
||||
s++;
|
||||
}
|
||||
|
||||
return hex*sign;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user