Live data from Hacker News

A word for a value between 0 and 1 (inclusive)

english.stackexchange.com

311–320 of 325 posts

Re: A word for a value between 0 and 1 (inclusive)

#311
post #285

Earlier quoted context omitted.

I don't think runtime validation is that special. You can bend most languages into this pattern one way or another. The real deal is having an actual compile-time-checked type that resembles a primitive.

Actually what I want is just the reading experience of seeing "public Customer GetById(CustomerId id)" instead of "public Customer GetById(string id)" when only some strings (e.g. 64 chars A-Z and 1-9) are valid customer ids. Compile-time validation would be ideal, but validation at the edges, well before that method, is good enough.

See: "Primitive Obsession" https://wiki.c2.com/?PrimitiveObsession

Usually cured by using Value objects. I wish this done more in OO code.

Could it be better supported in these languages? Yes, for sure. But is it true that "these language do not support such a type" at all? No.

Re: A word for a value between 0 and 1 (inclusive)

#312

Earlier quoted context omitted.

> However, I believe most of the more popular languages support creation of custom data types? No, most don't, except if you go into building custom classes.

So, most don't support custom types unless you...use the mechanism they have for defining a custom type? That seems a very elaborate way to say “No" when the answer is really “Yes”.

It's a succint way to say "No, not types that will automatically work as primitive types (which normally the variable passed for 0 to 1 would be), and that will work with numeric operators".

Or in other words, a succint way to say "Technically yes, but practically useless, so no".

Re: A word for a value between 0 and 1 (inclusive)

#313

Floating point boolean: It can convey True, False and all the grey in between.

This is about as good as it gets for the concept, but lacks as a name. I propose boof.

But actually there's two "natural" hardware implementations for this. First is like floating point with no sign bits (mantissa is positive or zero, exponent is negative). The other is fixed point, basically re-interpreting unsigned ints as being implicitly divided by 0xfff...f -- both have advantages and drawbacks. And then comes the operations. Multiplication is the only closed operation -- addition, subtraction and division need special cases: should they be clamped, or wrap around? Both, probably -- wrapping is useful for trig functions, for example.

Re: A word for a value between 0 and 1 (inclusive)

#314
post #264

Weird that it's been flagged as off-topic with no explanation. "I'm looking for a word" seems very on-topic for an stack exchange about a human language.

Among the comments: > Naming variables is expressly off-topic here. This question, and the answers to it, are the perfect showcase of why. – RegDwigнt The link "off-topic" in the notice eventually takes you to the help center which states: > But please, don’t ask any questions about the following topics. They are out of scope for this site. > * Naming, including naming programming variables/classes The question was e…

Gotcha on the edit... I saw a question that was more pertaining to documenting what a parameter is, which seems to be a valid question. Like other answers, portion or proportion seem like the most appropriate answer as part of a whole.

Re: A word for a value between 0 and 1 (inclusive)

#315
post #271
post #264

Earlier quoted context omitted.

Among the comments: > Naming variables is expressly off-topic here. This question, and the answers to it, are the perfect showcase of why. – RegDwigнt The link "off-topic" in the notice eventually takes you to the help center which states: > But please, don’t ask any questions about the following topics. They are out of scope for this site. > * Naming, including naming programming variables/classes The question was e…

It seems every StackExchange site is overrun by sophomoric gatekeepers, searching for (& competing with each other?) to find any possible reason to shoot-down questions. It's so much easier to hit that 'downvote' or 'close' button than to actually try to understand the asker, or compose a meaningful answer, or even explain clearly why a question might truly need work. So, I see a lot of 'closes' from people who hardl…

Not speaking to this question... but I largely don't even participate in stackoverflow anymore as most questions seem to be what should be an RTFA, have an existing answer, or homework help for what is way beyond the scope of the site.

It's frustrating when 9/10 of the questions aren't even deserving of an answer (at least that's my opinion) for the above reasons.

Re: A word for a value between 0 and 1 (inclusive)

#316
post #121

Earlier quoted context omitted.

While true, if your language doesn’t support such a type, then the burden for such a name goes to the parameter, does it not?

Or you could approach it another way, store the data using the full range of the system float type and normalize it to [0,1] through accessor methods. Can float types even support 0, 1 inclusive? You just can't represent natural numbers like that with floats...

The main issue with techniques such as this, which are certainly easy to do, is that if it’s not in the type system and therefore not checked at compile time, you pay a run time cost for these abstractions.

Re: A word for a value between 0 and 1 (inclusive)

#317
post #41

Earlier quoted context omitted.

Right. That's the thing we need a word for :) Unit Interval Value is nice but still a bit cumbersome. I mean if we all agreed right now it were called a "poog" then we could just say poog.

UnitInterval is the type. The name of the value should reflect its specific use.

UnitInterval isn't a type, it's a value of type Range, specifically the range [0,1].

UnitIntervalValue would be the type name for the thing we are interested in.

Values of that type should of course have descriptive names.

Re: A word for a value between 0 and 1 (inclusive)

#318
post #55

Earlier quoted context omitted.

UnitInterval is the type. The name of the value should reflect its specific use.

Exactly. The best usage for this would be something like: typedef float UnitInterval; void do_something_accurately(UnitInterval accuracy);

    typedef float UnitIntervalValue;

    void do_something_accurately(UnitIntervalValue accuracy);
FTFY

Re: A word for a value between 0 and 1 (inclusive)

#320
post #72
post #55

Earlier quoted context omitted.

Exactly. The best usage for this would be something like: typedef float UnitInterval; void do_something_accurately(UnitInterval accuracy);

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 cou…

ClosedUnitInterval 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.

Post reply on HN