假设float f = 4.4
如果我在某些内存读取器中浏览f
并假定f
是int
,则会得到值1082969293。
我不想像(int)f
那样将其强制转换为int
有没有办法假设f为int并在C#中获得该值(1082969293)?
最佳答案
float f = 4.4f;
var bytes = BitConverter.GetBytes(f);
int i = BitConverter.ToInt32(bytes, 0);
关于c# - 如何在不丢失小数的情况下将float转换为int?就像它在内存中显示的一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20710754/