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

I don't know how you would do that in practice, since every valid sequence of 4 or 8 bytes is a valid float. Maybe you could exclude some of the more unusual NaN representations but it still leaves you with most byte sequences being floats.

For example, the ASCII string "Morn", stored as the bytes '0b01001101 0b01101111 0b01110010 0b01101110', could be interpreted as the 32-bit float 0b01101110011100100110111101001101, representing the number 1.8757481691240478e+28.

So you couldn't really just have smart "float recognition" built in to an editor as a general feature, you would need some special format which the editor understands which communicates "the following 4 bytes is a single-precision float" or "the following 8-byte is a double-precision float".



Good point. It strikes me that Unicode is already analogous to recognition of multi byte characters. Maybe something along similar lines would work.




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

Search: