FloatIsNegative
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);Returns
true when the value is non-zero and has a negative sign.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:155:
}
bool FloatIsNegative(Float *value) {
ValidateFloat(value);
return !FloatIsZero(value) && value->negative;- In
Float.c:222:
ValidateFloat(value);
if (FloatIsNegative(value)) {
IntDeinit(&temp);
return false;- In
Float.c:398:
return 0;
}
if (FloatIsNegative(lhs) != FloatIsNegative(rhs)) {
return FloatIsNegative(lhs) ? -1 : 1;
}- In
Float.c:399:
}
if (FloatIsNegative(lhs) != FloatIsNegative(rhs)) {
return FloatIsNegative(lhs) ? -1 : 1;
}- In
Float.c:403:
cmp = float_abs_compare(lhs, rhs);
return FloatIsNegative(lhs) ? -cmp : cmp;
}- In
Float.c:588:
IntMul(&temp.significand, &a->significand, &b->significand);
temp.negative = FloatIsNegative(a) != FloatIsNegative(b);
temp.exponent = float_add_i64_checked(a->exponent, b->exponent);- In
Float.c:652:
IntDiv(&temp.significand, &scaled, &b->significand);
temp.negative = FloatIsNegative(a) != FloatIsNegative(b);
temp.exponent = float_sub_i64_checked(float_sub_i64_checked(a->exponent, b->exponent), (i64)precision);
bool result = strcmp(text.data, "42") == 0;
result = result && !FloatIsNegative(&value);
StrDeinit(&text);
bool result = strcmp(text.data, "-42") == 0;
result = result && FloatIsNegative(&value);
StrDeinit(&text);
bool test_float_is_negative(void) {
WriteFmt("Testing FloatIsNegative\n");
Float neg = FloatFromStr("-42"); Float zero = FloatFromStr("-0.0");
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);- In
Float.Type.c:17:
bool result = FloatIsZero(&value);
result = result && !FloatIsNegative(&value);
result = result && (FloatExponent(&value) == 0);- In
Float.Type.c:32:
bool result = FloatIsZero(&value);
result = result && !FloatIsNegative(&value);
result = result && (FloatExponent(&value) == 0);
Last updated on