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:302:
}
bool FloatIsNegative(const Float *value) {
ValidateFloat(value);
return !FloatIsZero(value) && value->negative;- In
Float.c:439:
Int temp = IntInit(IntAllocator(result));
if (FloatIsNegative(value)) {
IntDeinit(&temp);
return false;- In
Float.c:744:
return 0;
}
if (FloatIsNegative(lhs) != FloatIsNegative(rhs)) {
return FloatIsNegative(lhs) ? -1 : 1;
}- In
Float.c:745:
}
if (FloatIsNegative(lhs) != FloatIsNegative(rhs)) {
return FloatIsNegative(lhs) ? -1 : 1;
}- In
Float.c:754:
return 0;
}
return FloatIsNegative(lhs) ? -cmp : cmp;
}- In
Float.c:1128:
return false;
}
temp.negative = FloatIsNegative(a) != FloatIsNegative(b);
temp.exponent = float_add_i64_checked(a->exponent, b->exponent);- In
Float.c:1225:
}
temp.negative = FloatIsNegative(a) != FloatIsNegative(b);
temp.exponent = float_sub_i64_checked(float_sub_i64_checked(a->exponent, b->exponent), (i64)precision);- In
Type.c:22:
bool result = FloatIsZero(&value);
result = result && !FloatIsNegative(&value);
result = result && (FloatExponent(&value) == 0);- In
Type.c:40:
bool result = FloatIsZero(&value);
result = result && !FloatIsNegative(&value);
result = result && (FloatExponent(&value) == 0);- In
Math.c:690:
Float pos = FloatFrom(1.0f, &alloc.base);
bool result = FloatIsNegative(&neg) && !FloatIsNegative(&pos);
FloatDeinit(&neg);- In
Math.c:748:
Float pos = FloatFrom(1.0, &alloc.base);
bool result = FloatIsNegative(&neg) && !FloatIsNegative(&pos);
FloatDeinit(&neg);- In
Convert.c:57:
bool result = ZstrCompare(StrBegin(&text), "42") == 0;
result = result && !FloatIsNegative(&value);
StrDeinit(&text);- In
Convert.c:74:
bool result = ZstrCompare(StrBegin(&text), "-42") == 0;
result = result && FloatIsNegative(&value);
StrDeinit(&text);- In
Convert.c:360:
Str text = FloatToStr(&value);
result = result && FloatIsNegative(&value);
result = result && (ZstrCompare(StrBegin(&text), "-2000") == 0);
result = result && (FloatExponent(&value) == 3);- In
Access.c:29:
bool test_float_is_negative(void) {
WriteFmt("Testing FloatIsNegative\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Access.c:37:
Float zero = FloatFromStr("-0.0", &alloc.base);
bool result = FloatIsNegative(&neg);
result = result && !FloatIsNegative(&pos);
result = result && !FloatIsNegative(&zero);- In
Access.c:38:
bool result = FloatIsNegative(&neg);
result = result && !FloatIsNegative(&pos);
result = result && !FloatIsNegative(&zero);- In
Access.c:39:
bool result = FloatIsNegative(&neg);
result = result && !FloatIsNegative(&pos);
result = result && !FloatIsNegative(&zero);
FloatDeinit(&neg);
Last updated on