FloatClone
Description
Create a deep copy of a floating-point value.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Float to clone |
Usage example (from documentation)
Float copy = FloatClone(&value);Success
Returns an independent deep copy of value (sign, significand bits, exponent) bound to value’s allocator. value is not modified.
Failure
Returns a freshly initialised empty Float bound to value’s allocator on allocation failure during the significand copy. The caller cannot distinguish that from a true zero result; use FloatTryClone directly when explicit failure propagation is required.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:284:
}
Float FloatClone(const Float *value) {
Float clone;- In
Float.Type.c:48:
bool test_float_clone(void) {
WriteFmt("Testing FloatClone\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Type.c:53:
Float original = FloatFromStr("-12.5", &alloc.base);
Float clone = FloatClone(&original);
Float expected = FloatFromStr("-12.5", &alloc.base);
Str text = FloatToStr(&clone);- In
Float.Type.c:72:
bool test_float_clone_inherits_allocator_config(void) {
WriteFmt("Testing FloatClone allocator inheritance\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Type.c:86:
Float original = FloatFromStr("-0.005", &alloc.base);
Float clone = FloatClone(&original);
bool result = FloatEQ(&clone, &original) && FloatAllocator(&clone) == FloatAllocator(&original) &&
Last updated on