Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


You can't represent the interval from 0 to 1 inclusive without significant run time cost just because of the way floats work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: