Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the fdim acronym stand for?

All C math functions seems to have an understandable name, but I can't find what the fdim acronym stands for. (fdim computes the positive difference of it two floating-point inputs).

like image 762
Pyoz_ Avatar asked Jan 25 '23 07:01

Pyoz_


2 Answers

I searched the ISO-C working group's document archive, and noticed that most of the proposals for the floating-point enhancements to what would become C99 were contributed by Jim Thomas. Best I can tell, fdim was included in the draft new standard prior to 1996, and unfortunately the archive does not provide links to electronic copies for proposals from that time.

So I contacted Mr. Thomas directly via email and received a response, the relevant portion of which I quote here with his permission:

From: Jim Thomas
To: Norbert Juffa
Time: Sat 2/15/2020 8:42 AM
Subject: Re: Naming of, and rationale for, the fdim() function in ISO-C99
[...]
The C fdim function is the C versions for the Fortran DIM (positive difference) function. The C function, and its name, were intended for programmers porting code form Fortran to C.

This confirms the linkage with Fortran alluded to in comments. As for the name DIM itself, Ctx's answer addresses this as well as one could hope for in the case of a minor function that has been around for fifty years.

In comments below the question, Mark Dickinson pointed to the Fortran 66 standard, which on page 23 defined Fortran's DIM function as a₁ - Min (a₁, a₂). This provides further evidence that the name DIM is a contraction of DIfference and Minimum.

like image 74
njuffa Avatar answered Jan 29 '23 11:01

njuffa


My guess is, that it is a composition from difference and max, because this is what the function does.

Pseudo-code

double fdim(x, y) { 
    float    tmp = x - y;        // 1st step: "di"fference
    float result = fmax(tmp, 0); // 2nd step: "m"aximum
    return result;
}

Same nomenclature for example with fma(a, b, c), which means "multiply" and "add" (a*b+c)

Edit:

The function indeed occurred even earlier in Fortran, where the function DIM(number, number) is defined as

A function that returns the value of the first argument minus the minimum (MIN) of the two arguments.

so the function name is derived from difference and minimum here. See the F77 DIM manual

like image 20
Ctx Avatar answered Jan 29 '23 13:01

Ctx