Or at very least an absolute normalized float
A word for a value between 0 and 1 (inclusive)
11–20 of 325 posts
Wouldn’t this be a normalized / unitized float?
Re: A word for a value between 0 and 1 (inclusive)
#12I'd personally go with "percent", but because there's so many correct options, it shouldn't matter as long as it's consistent in the code base. Otherwise it just becomes bike-shedding bait.
Re: A word for a value between 0 and 1 (inclusive)
#13I'd personally go with "percent", but because there's so many correct options, it shouldn't matter as long as it's consistent in the code base. Otherwise it just becomes bike-shedding bait.
Right but it’s specifically not, and liable to make people think “3” is an acceptable input
Re: A word for a value between 0 and 1 (inclusive)
#14The real answer to this XY is comments and documentation, imo. If you want to make it obvious without reading docs or code, get an IDE with doxygen-aware completion.
Edit: also, put it into typename, not into argname.
Re: A word for a value between 0 and 1 (inclusive)
#15"float zero_to_one" is pretty short and obvious. The caller can maybe even guess by the context of the function name that it probably accepts 0 and 1.
Re: A word for a value between 0 and 1 (inclusive)
#16I typically use "_fraction" to indicate this in floating point variable names, along with a comment explicitly mentioning the range from 0 to 1 somewhere. Seems to minimize confusion pretty well.
Re: A word for a value between 0 and 1 (inclusive)
#17Given that no existing word is quite right for this common problem, a neologism is best. And "primantissa" delights: I will smile every time I use it.
[deleted]
Re: A word for a value between 0 and 1 (inclusive)
#18Perunit
Re: A word for a value between 0 and 1 (inclusive)
#19Re: A word for a value between 0 and 1 (inclusive)
#20Better languages will let you call the variable just "accuracy", but with type "float 0 to 1 inclusive" with some literal syntax; so from
function FuncName(float AccuracySOMETHING)
to function FuncName([0...1] accuracy)