3
$\begingroup$

In the new version of IEEE-754-2019: IEEE Standard for floating-point arithmetic, the augmented arithmetic operations were introduced. These operations can be particularly useful in certain numerical schemes.

In the paper "The IEEE Standard 754: One for the History Books" (also available here), it is described, as follows:

The most interesting new feature of IEEE Standard 754-2019 is the augmented arithmetic operations. These provide the exact result of an addition, subtraction, or multiplication in two parts that add up to the exact result.

From what I understand, that would mean that the implementation of IEEE-754-2019 arithmetic will have to compute both the value of the operation (1) and the introduced error (2):

$$ \text{fl}\left(x\circ y \right) \tag{1} $$

$$ \text{fl}\Big(\text{fl}\left(x\circ y \right) - \left(x\circ y\right)\Big) \tag{2} $$

In (1) and (2), $\text{fl}(x)$ denotes rounding mapping a real number $x$ into the set of floating-point numbers, and $\circ$ denotes the supported augmented arithmetic operations.

This means that the augmented arithmetic operation has to return two values. I wonder if my understanding is correct, and (2) are correct. Is it the first operation in IEEE-754 that has several "returns"?

If that's right, that would mean that in the C-like language it can be implemented only as a procedure:

augmentedArithmOperation(x, y, &res, &error);

since returning several output arguments is not supported.

$\endgroup$
1
  • $\begingroup$ I think you can compare this to double-precision complex floats -- the real/imaginary part are analogous to the result/error estimate. You could implement either one by returning a struct with the relevant parts. I also found this paper where they propose the functionality but not what the C API for it should be. $\endgroup$ May 26, 2020 at 19:18

1 Answer 1

2
$\begingroup$

C doesn't allow multiple returns as such but the result could be packed into a struct.

struct augmented_double {
    double head;
    double tail;
};

struct augmented_double augmented_add(double, double);
struct augmented_double augmented_multiply(double, double);

You can do this for any function that returns multiple values, it's just cumbersome because you need to separately declare a new struct for the return type of every function that does so. In C++11 you could just return a std::tuple. As far as I know most existing implementations of augmented arithmetic use an API like what you've shown, where the results are written to pointer arguments, but that doesn't mean it's the only way. Also the new floating point standard specifies that conforming implementations have to provide augmented arithmetic, not that the behavior of existing arithmetic operations needs to change. You probably won't ever be able to use this with the regular old + and * operators.

Alternatively, on x86 systems with SSE2 instructions, the result could be written into a SIMD type like __m128d, which you could typedef to augmented_double to signal the intended usage.

Hopefully the C2x revision to the C language standard will include support for augmented arithmetic. In that case, the new standard would need to:

  • add a type for augmented floats into the <float.h> header
  • define augmented arithmetic operations
  • define helper functions to extract the head and tail
  • do all the necessary platform introspection to determine how best to represent augmented FP types

The last step is where the compiler writers would determine to, say, represent augmented FP types as __m128d on systems that have SIMD registers, and as a struct with two doubles on systems that don't.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.