4 ms·
This is the correct answer IMHO. (The variable name could also be "proportion" or "probability" depending on context, and the type name could more precisely be
by Tainnor 6y ago
This is the correct answer IMHO. (The variable name could also be "proportion" or "probability" depending on context, and the type name could more precisely be ClosedUnitInterval, but the idea of putting it in the type is IMHO correct.)
I don't know much about C (? I assume that's what this is), but in other languages you can even build a wrapper type and enforce invariants in construction if really necessary.
Of course, all that ceremony only makes sense if this is really a type you use multiple times. Otherwise I wouldn't bother.
- nicky0 6y agoClosedUnitInterval surely describes the interval itself, not a member of that interval. The member would be ClosedUnitIntervalValue or something. This is the thing it would be nice to have a short name for. Just as we say an integer is a member of the set called the integers. We say our "X" (the word we are looking for) is a member of the set called the closed unit interval.