FloatIsNegative
Description
Test whether a floating-point value is negative.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Float to test |
Usage example (from documentation)
bool negative = FloatIsNegative(&value);Success
Returns true when the value is non-zero and has a negative sign.
Failure
Returns false otherwise. Cannot fail.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:274:
}
bool FloatIsNegative(const Float *value) {
ValidateFloat(value);
return !FloatIsZero(value) && value->negative;- In
Float.c:411:
Int temp = IntInit(IntAllocator(result));
if (FloatIsNegative(value)) {
IntDeinit(&temp);
return false;- In
Float.c:716:
return 0;
}
if (FloatIsNegative(lhs) != FloatIsNegative(rhs)) {
return FloatIsNegative(lhs) ? -1 : 1;
}- In
Float.c:717:
}
if (FloatIsNegative(lhs) != FloatIsNegative(rhs)) {
return FloatIsNegative(lhs) ? -1 : 1;
}- In
Float.c:726:
return 0;
}
return FloatIsNegative(lhs) ? -cmp : cmp;
}- In
Float.c:1100:
return false;
}
temp.negative = FloatIsNegative(a) != FloatIsNegative(b);
temp.exponent = float_add_i64_checked(a->exponent, b->exponent);- In
Float.c:1197:
}
temp.negative = FloatIsNegative(a) != FloatIsNegative(b);
temp.exponent = float_sub_i64_checked(float_sub_i64_checked(a->exponent, b->exponent), (i64)precision);- In
Float.Type.c:21:
bool result = FloatIsZero(&value);
result = result && !FloatIsNegative(&value);
result = result && (FloatExponent(&value) == 0);- In
Float.Type.c:39:
bool result = FloatIsZero(&value);
result = result && !FloatIsNegative(&value);
result = result && (FloatExponent(&value) == 0);
bool result = ZstrCompare(StrBegin(&text), "42") == 0;
result = result && !FloatIsNegative(&value);
StrDeinit(&text);
bool result = ZstrCompare(StrBegin(&text), "-42") == 0;
result = result && FloatIsNegative(&value);
StrDeinit(&text);
bool test_float_is_negative(void) {
WriteFmt("Testing FloatIsNegative\n");
DefaultAllocator alloc = DefaultAllocatorInit(); Float zero = FloatFromStr("-0.0", &alloc.base);
bool result = FloatIsNegative(&neg);
result = result && !FloatIsNegative(&pos);
result = result && !FloatIsNegative(&zero);
bool result = FloatIsNegative(&neg);
result = result && !FloatIsNegative(&pos);
result = result && !FloatIsNegative(&zero); bool result = FloatIsNegative(&neg);
result = result && !FloatIsNegative(&pos);
result = result && !FloatIsNegative(&zero);
FloatDeinit(&neg);
Last updated on