[英]how to convert a decimal number into 64 bit floating point number in C program?
I am working on block compressed sparse row format of sparse matrix. 我正在研究稀疏矩阵的块压缩稀疏行格式。 I need to convert a nonzero element into 64 bit floating point. 我需要将一个非零元素转换为64位浮点数。 I need a syntax in c OR C++ for that? 我需要使用C或C ++的语法吗?
Do you have your number saved as a string? 您的号码是否另存为字符串? If yes do (this will work in both C and C++): 如果是的话(这将在C和C ++中都起作用):
const char *number = "11.111"; // This the variable holding your number
double num = atof(number); // This is your number saved as a double, that is usually 64 bit
If you have it saved as an int
, double
, float
you can simply do: 如果将其另存为int
, double
, float
,则只需执行以下操作:
double num = other_variable;
Again, it will work in both C and C++. 同样,它将在C和C ++中都可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.