FloatFrom
Description
Convert a numeric value into an arbitrary-precision float. Dispatches on the type of value. The allocator argument may be a typed allocator pointer (&heap) or a raw Allocator *.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer, Int, float, or double source value |
Usage example (from documentation)
DefaultAllocator a = DefaultAllocatorInit();
Float value = FloatFrom(42, &a);Success
Returns Float representing the same numeric value.
Failure
Returns an empty (zero) Float bound to the given allocator when the underlying conversion cannot complete (allocation failure on the significand, or an unsupported non-finite native-float input). The caller cannot distinguish that from a true-zero source without a prior IntTry* / FloatIsZero check; use the *Try* form when detection matters.
Usage example (Cross-references)
Usage examples (Cross-references)
bool test_float_from_unsigned_integer(void) {
WriteFmt("Testing FloatFrom with unsigned integer\n");
DefaultAllocator alloc = DefaultAllocatorInit();
bool test_float_from_signed_integer(void) {
WriteFmt("Testing FloatFrom with signed integer\n");
DefaultAllocator alloc = DefaultAllocatorInit();
bool test_float_from_int_container(void) {
WriteFmt("Testing FloatFrom with Int container\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Last updated on