How to get the bits of a “double” as a “long”

后端 未结 3 1531
太阳男子
太阳男子 2021-02-20 04:58

I would like to manipulate the bitwise representation of floating-point numbers in C#. BinaryWriter and BinaryReader do it this way:

public virtual unsafe void W         


        
3条回答
  •  误落风尘
    2021-02-20 05:32

    You can use byte[] BitConverter.GetBytes(double) and long BitConverter.ToInt64(byte[],int) (passing 0 as the start-index), but internally IIRC these use unsafe code, plus have the overhead of an array. Pick your poison...

提交回复
热议问题