forked from Mirrors/openclonk
C4Value Arithmetic Assignment Operators: Fix integer operation 64vs32bit consistency
var ov = 0x7fffffff, counter = 0x80000000; while(++counter <= 1) ov++; Format("%v %v", ov, !ov); would return "0 false" on a 64 bit system, exists since CRfloating-point
parent
9b8cfac66e
commit
548a1047b9
|
@ -132,7 +132,7 @@ StdStrBuf C4Value::GetDataString(int depth) const
|
|||
switch (GetType())
|
||||
{
|
||||
case C4V_Int:
|
||||
return FormatString("%ld", static_cast<long>(Data.Int));
|
||||
return FormatString("%ld", static_cast<long>(_getInt()));
|
||||
case C4V_Float:
|
||||
return FormatString("%f", static_cast<float>(C4Real(Data.Float)));
|
||||
case C4V_Bool:
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
|
||||
void Set(const C4Value &nValue) { Set(nValue.Data, nValue.Type); }
|
||||
|
||||
void SetInt(int i) { C4V_Data d; d.Int = i; Set(d, C4V_Int); }
|
||||
void SetInt(int32_t i) { C4V_Data d; d.Int = i; Set(d, C4V_Int); }
|
||||
void SetFloat(C4Real f)
|
||||
{
|
||||
C4V_Data d;
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
Data.Int op##= rhs.Data.Int; \
|
||||
Data.Int = _getInt() op rhs._getInt(); \
|
||||
Type=C4V_Int; \
|
||||
} \
|
||||
return *this; \
|
||||
|
@ -189,9 +189,10 @@ public:
|
|||
switch (Type)
|
||||
{
|
||||
case C4V_Nil:
|
||||
case C4V_Int:
|
||||
case C4V_Bool:
|
||||
++Data.Int; Type = C4V_Int; break;
|
||||
Type = C4V_Int; //nobreak
|
||||
case C4V_Int:
|
||||
Data.Int = _getInt() + 1; break;
|
||||
case C4V_Float:
|
||||
SetFloat(getFloat() + 1.0f); break;
|
||||
default:
|
||||
|
@ -210,9 +211,10 @@ public:
|
|||
switch (Type)
|
||||
{
|
||||
case C4V_Nil:
|
||||
case C4V_Int:
|
||||
case C4V_Bool:
|
||||
--Data.Int; Type = C4V_Int; break;
|
||||
Type = C4V_Int; //nobreak
|
||||
case C4V_Int:
|
||||
Data.Int = _getInt() - 1; break;
|
||||
case C4V_Float:
|
||||
SetFloat(getFloat() - 1.0f); break;
|
||||
default:
|
||||
|
@ -232,8 +234,8 @@ public:
|
|||
switch (Type)
|
||||
{
|
||||
case C4V_Nil:
|
||||
case C4V_Int:
|
||||
case C4V_Bool:
|
||||
case C4V_Int:
|
||||
nrv.Data.Int = -Data.Int;
|
||||
nrv.Type = C4V_Int;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue