4 ms·
Genuine question, can you be sure the conversion wouldn't introduce a wrong bit here or there? Maybe in a different architecture or something? I'm not that goo
by jalbertoni 5y ago
Genuine question, can you be sure the conversion wouldn't introduce a wrong bit here or there? Maybe in a different architecture or something?
I'm not that good with CPUs past 16 bits, this is really out of my comfort zone heh
- bombcar 5y agoI think the format for single precision and double is defined by the standard. Beyond that may be implementation dependent.
- _kst_ 5y agoThe format for floating-point is specified by the IEEE floating-point standard (or whatever it's officially called these days). C permits but does not require IEEE format. Most implementations these days use it.
- banana_giraffe 5y agoUnless I'm missing something, this code is already architecture dependent .. adding more architecture dependencies won't really hurt.
- grishka 5y agoYou only depend on the compiler to interpret these floats correctly and generate their binary representation that decodes into valid instructions. As far as the CPU executing this code is concerned, it's machine code either way. > Maybe in a different architecture or something? Of course this isn't portable across CPU architectures, neither is it portable across operating systems due to at least ABI differences.
- jalbertoni 5y agoOh, I think you misunderstood me. Sorry. I meant like, how can you be sure a compiler would interpret them correctly and give you the exact binary value you wanted. And by different architectures, I meant more like, if you compiled it on Intel and AMD, could the results be different? Though I guess this part of the question makes no sense now that I think more on it.