MATLAB: How to set individual bits in 64-bit double-precision floating number

MATLAB

Hi everyone,
I am wondering if it is possible to set individual bits in 64-bit double-precision floating number in MATLAB.
I know that I can use "format hex" to read the bits. But how can I set it?
Thanks Kevin

Best Answer

Example:
typecast(bitset(typecast(pi,'uint64'),53,1),'double')
Bit numbering is 64 for the most significant bit, down to 1 for the least significant bit.
As the IEEE 754 floating point representation is being altered, the change I made here of effectively adding 1 to the exponent resulting in doubling the result (because IEEE 754 has binary representation, not decimal representation.)
Related Question