I have a function that takes a numerical value V and a tolerance value T and does the following:

if (-T < V < T)
    set V to 0,
    do nothing.

So it turns values near zero into zero. This function is called "coerce" (by the people who programmed the function).

Some questions:

  • Is it a suitable name for the function from the language usage point of view?

I only know coerce in the context of forcing so/sth INTO DOING sth. The above situiation is more like forcing so/sth INTO BEING or BECOMING sth, so I was wondering if some other verb has to be used in this situation.

  • Lets consider a similar function that takes a value V, another value A and the tolerance T and does the following:

    if (A-T < V < A+T)
        set V to A,
        do nothing.

So this function turns values near A into A. I'd like to give the function a similar name, but this time with a preposition that indicates "towardness".

What would be the right preposition for its name? CoerceInto? CoerceTowards? Or something else?

  • Becoming zero is doing something. Sep 9, 2016 at 10:33

2 Answers 2


In programming, the term coercion is used when a variable of one type is automatically changed by the compiler to another type. If done correctly, it does not affect the value of the variable, only how it is represented. The term is used because the variable is effectively forced to the new type. The preposition used for coercion is to.

The activity that you describe would probably be better covered by the word rounding, and again, the preposition to is used, for example

Value within T of A are rounded to A.

  • I feel rounding does not fit here. Rounding takes always place (for every number inserted into the rounding function). In my function, rounding only takes place under certain circumstances. Also, all rounding functions have some shared properties like monotonicity (i.e. if x <= y, then rounded(x) <= rounded(y)), which my function does not have. Do you have other suggestions?
    – Kjara
    Jul 25, 2016 at 12:33

I'm not aware of a proper name for this concept. I'd name the function SnapToValue() or similar.

  • 1
    I like that idea: I guess you are thinking of the "snap to grid" facility in graphics applications.
    – JavaLatte
    Jul 26, 2016 at 5:47
  • @JavaLatte Exactly!
    – TarkaDaal
    Jul 26, 2016 at 11:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .