In the softfloat.c file there is a function called float64_add(). What I need is a way to pack and canonicalize a FloatParts value. There doesn't appear to be any way. This is what I have tried so far, but the results are not good. The intermediate_result and the rounded_result should be close to each other. What currently happens is the values are very far from each other.
float64 __attribute__((flatten)) float64_add(float64 a, float64 b, float_status *status) { FloatParts pa = float64_unpack_canonical(a, status); FloatParts pb = float64_unpack_canonical(b, status); FloatParts pr = addsub_floats(pa, pb, false, status); FloatParts intermediate_parts = canonicalize(pr, &float64_params, status); float64 intermediate_result = float64_pack_raw(intermediate_parts); float64 rounded_result = float64_round_pack_canonical(pr, status); if (intermediate_result != rounded_result) { printf("a = 0x%" PRIx64 "\n", a); printf("b = 0x%" PRIx64 "\n", b); printf("intermediate result: 0x%" PRIx64 "\n", intermediate_result); printf("rounded result: 0x%" PRIx64 "\n", rounded_result); } return rounded_result; } Here is some example output: a = 0x40b11f0000000000 4383 b = 0x4076d00000000000 365 intermediate result: 0x40d0000000000000 16384 rounded result: 0x40b28c0000000000 4748 Here the intermediate result is way bigger than the rounded result. What I hope to do is implement a PowerPC CPU flag that indicates if an rounded result is inexact.