4 ms·
yeah, right, so what do you call such a type? I believe that is the actual question.
by firstbabylonian 6y ago
yeah, right, so what do you call such a type? I believe that is the actual question.
- StavrosK 6y agoThe question was about the parameter name, though. The correct answer seems to be: function FuncName(UnitInterval accuracy)
- elcomet 6y agoUnitInterval seems to contains an interval, not a single float. I don't think it's a very good name. UnitIntervalNumber would be better, but it's too long. Something like UnitNumber or UnitFloat could maybe work.
- peterhil 6y agoAfter reading this reply twice, I realised you are right and UnitInterval type indicates an interval object instead of a single scalar number. I have actually used intervals, and should have realised this sooner. But I just had my first cup of coffee...
- dmurray 6y agoYes, UnitInterval is a really bad name for a single number. Astonishingly, it has 30 upvotes on SO.
- ajuc 6y agofunction FuncName(NormalizedFloat accuracy) In languages with operator overloading you can make NormalizedFloat a proper class with asserts in debug version and change it to an alias of float in release version. Similarly I wonder why gemoetry libraries don't define separate Point class and Vector class, they almost always use Vector class for vectors and points. I understand math checks out, and sometimes you want to add or multiply points, for example: Pmid = (P0 + P1) / 2 But you could cast in such instances: Pmid = (P0 + (Vector)P1)/ 2 And the distinction would surely catch some errors. Point - Point = Vector Point + Point = ERROR Vector +/- Vector = Vector Point +/- Vector = Point Point * scalar = ERROR Vector * scalar = Vector Point */x Point = ERROR Vector * Vector = scalar Vector x Vector = Vector