mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Deprecate uXX and iXX bit suffixes.
Add experimental LL / ULL suffixes for int128 and uint128 literals.
This commit is contained in:
@@ -507,7 +507,7 @@ macro bool is_finite(x)
|
||||
$case float16:
|
||||
return bitcast((float)x, uint) & 0x7fffffff < 0x7f800000;
|
||||
$default:
|
||||
return bitcast((double)x, ulong) & (~0u64 >> 1) < 0x7ffu64 << 52;
|
||||
return bitcast((double)x, ulong) & (~0UL >> 1) < 0x7ffUL << 52;
|
||||
$endswitch
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ macro is_nan(x)
|
||||
$case float16:
|
||||
return bitcast((float)x, uint) & 0x7fffffff > 0x7f800000;
|
||||
$default:
|
||||
return bitcast((double)x, ulong) & (~0u64 >> 1) > 0x7ffu64 << 52;
|
||||
return bitcast((double)x, ulong) & (~0UL >> 1) > 0x7ffUL << 52;
|
||||
$endswitch
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ macro is_inf(x)
|
||||
$case float16:
|
||||
return bitcast((float)x, uint) & 0x7fffffff == 0x7f800000;
|
||||
$default:
|
||||
return bitcast((double)x, ulong) & (~0u64 >> 1) == 0x7ffu64 << 52;
|
||||
return bitcast((double)x, ulong) & (~0UL >> 1) == 0x7ffUL << 52;
|
||||
$endswitch
|
||||
}
|
||||
|
||||
@@ -1053,8 +1053,8 @@ fn double _frexp(double x, int* e)
|
||||
return x;
|
||||
default:
|
||||
*e = ee - 0x3fe;
|
||||
i &= 0x800fffffffffffffu64;
|
||||
i |= 0x3fe0000000000000u64;
|
||||
i &= 0x800fffffffffffffUL;
|
||||
i |= 0x3fe0000000000000UL;
|
||||
return bitcast(i, double);
|
||||
}
|
||||
}
|
||||
@@ -1079,8 +1079,8 @@ fn float _frexpf(float x, int* e)
|
||||
return x;
|
||||
default:
|
||||
*e = ee - 0x7e;
|
||||
i &= 0x807fffffu32;
|
||||
i |= 0x3f000000u32;
|
||||
i &= 0x807fffffU;
|
||||
i |= 0x3f000000U;
|
||||
return bitcast(i, float);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ fn double _exp2_specialcase(double tmp, ulong sbits, ulong ki) @private
|
||||
if (ki & 0x80000000 == 0)
|
||||
{
|
||||
// k > 0, the exponent of scale might have overflowed by 1.
|
||||
sbits -= 1u64 << 52;
|
||||
sbits -= 1UL << 52;
|
||||
double scale = bitcast(sbits, double);
|
||||
double y = 2 * (scale + scale * tmp);
|
||||
return y;
|
||||
}
|
||||
// k < 0, need special care in the subnormal range.
|
||||
sbits += 1022u64 << 52;
|
||||
sbits += 1022UL << 52;
|
||||
double scale = bitcast(sbits, double);
|
||||
double y = scale + scale * tmp;
|
||||
if (y >= 1.0)
|
||||
|
||||
@@ -31,4 +31,4 @@ fn char SimpleRandom.next_byte(&self) @dynamic => (char)self.next_int();
|
||||
|
||||
const long SIMPLE_RANDOM_MULTIPLIER @local = 0x5DEECE66D;
|
||||
const long SIMPLE_RANDOM_ADDEND @local = 0xB;
|
||||
const long SIMPLE_RANDOM_MASK @local = (1u64 << 48) - 1;
|
||||
const long SIMPLE_RANDOM_MASK @local = (1UL << 48) - 1;
|
||||
|
||||
@@ -315,15 +315,15 @@ macro float_from_i128($Type, a) @private
|
||||
const MANT_DIG = math::DOUBLE_MANT_DIG;
|
||||
const SIGNIFICANT_BITS = 52;
|
||||
const EXP_BIAS = 1023;
|
||||
const MANTISSA_MASK = 0xFFFFF_FFFF_FFFFu64;
|
||||
const SIGN_BIT = 1u64 << 63;
|
||||
const MANTISSA_MASK = 0xFFFFF_FFFF_FFFFUL;
|
||||
const SIGN_BIT = 1UL << 63;
|
||||
$case float:
|
||||
$Rep = uint;
|
||||
const MANT_DIG = math::FLOAT_MANT_DIG;
|
||||
const EXP_BIAS = 127;
|
||||
const SIGNIFICANT_BITS = 23;
|
||||
const MANTISSA_MASK = 0x7F_FFFFu32;
|
||||
const SIGN_BIT = 1u32 << 31;
|
||||
const MANTISSA_MASK = 0x7F_FFFFU;
|
||||
const SIGN_BIT = 1U << 31;
|
||||
$case float16:
|
||||
$Rep = ushort;
|
||||
const MANT_DIG = math::HALF_MANT_DIG;
|
||||
@@ -352,7 +352,7 @@ macro float_from_i128($Type, a) @private
|
||||
a |= (uint128)((a & 4) != 0);
|
||||
a++;
|
||||
a >>= 2;
|
||||
if (a & (1i128 << MANT_DIG))
|
||||
if (a & (1LL << MANT_DIG))
|
||||
{
|
||||
a >>= 1;
|
||||
e++;
|
||||
@@ -374,13 +374,13 @@ macro float_from_u128($Type, a) @private
|
||||
const MANT_DIG = math::DOUBLE_MANT_DIG;
|
||||
const SIGNIFICANT_BITS = 52;
|
||||
const EXP_BIAS = 1023;
|
||||
const MANTISSA_MASK = 0xFFFFF_FFFF_FFFFu64;
|
||||
const MANTISSA_MASK = 0xFFFFF_FFFF_FFFFUL;
|
||||
$case float:
|
||||
$Rep = uint;
|
||||
const MANT_DIG = math::FLOAT_MANT_DIG;
|
||||
const EXP_BIAS = 127;
|
||||
const SIGNIFICANT_BITS = 23;
|
||||
const MANTISSA_MASK = 0x7F_FFFFu32;
|
||||
const MANTISSA_MASK = 0x7F_FFFFU;
|
||||
$case float16:
|
||||
$Rep = ushort;
|
||||
const MANT_DIG = math::HALF_MANT_DIG;
|
||||
@@ -406,7 +406,7 @@ macro float_from_u128($Type, a) @private
|
||||
a |= (uint128)((a & 4) != 0);
|
||||
a++;
|
||||
a >>= 2;
|
||||
if (a & (1i128 << MANT_DIG))
|
||||
if (a & (1LL << MANT_DIG))
|
||||
{
|
||||
a >>= 1;
|
||||
e++;
|
||||
@@ -458,8 +458,8 @@ macro fixuint(a) @private
|
||||
int sign = rep & SIGN_BIT ? -1 : 1;
|
||||
int exponent = (int)((abs >> SIGNIFICANT_BITS) - EXPONENT_BIAS);
|
||||
$Rep significand = (abs & SIGNIFICANT_MASK) | IMPLICIT_BIT;
|
||||
if (sign == -1 || exponent < 0) return 0u128;
|
||||
if ((uint)exponent >= uint128.sizeof * 8) return ~0u128;
|
||||
if (sign == -1 || exponent < 0) return 0ULL;
|
||||
if ((uint)exponent >= uint128.sizeof * 8) return ~0ULL;
|
||||
if (exponent < SIGNIFICANT_BITS) return (uint128)significand >> (SIGNIFICANT_BITS - exponent);
|
||||
return (uint128)significand << (exponent - SIGNIFICANT_BITS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user