math.Dim naming origin

67 views
Skip to first unread message

Uwe Dauernheim

unread,
Jan 8, 2016, 12:24:16 PM1/8/16
to golang-nuts
Could someone explain the idea behind giving `math.Dim` its name? Maybe this explanation could be integrated into the doc string?

I assume it comes from dimension or dimensionality and express these never can't be negative?

Iff, are the arguments float to align with the rest in the package? I could image dimensions not to be float in mathematics.

I'm also curious to know what made it a better choice (besides length) than ensureNonNegative, assertNonNegative, keepRange, inRange, etc.


Ian Lance Taylor

unread,
Jan 8, 2016, 12:41:22 PM1/8/16
to Uwe Dauernheim, golang-nuts
math.Dim is the Go version of the C99 fdim function. That in turn
comes from the Fortran DIM function. The name in Fortran may come
from "difference from minimum." DIM(x, y) returns the difference
between x and the minimum of x and y.

in general any C math function is automatically OK for Go's math
package with approximately the same name (the 'f' needed in C is not
needed in Go, where the package specifier math is sufficient). Any
other function, or a different name, requires justification.

Ian
Reply all
Reply to author
Forward
0 new messages