我需要将 float 转换为 int(单精度,32 位),例如:
' float :2(十六进制:40000000)到整数:1073741824'。知道如何实现吗?
我在 msdn 帮助中寻找它,但没有结果。
最佳答案
float f = ...;
int i = BitConverter.ToInt32(BitConverter.GetBytes(f), 0);
关于c# 如何将 float 转换为 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7173677/