[英]how to convert a decimal number into 64 bit floating point number in C program?
我正在研究稀疏矩陣的塊壓縮稀疏行格式。 我需要將一個非零元素轉換為64位浮點數。 我需要使用C或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
如果將其另存為int
, double
, float
,則只需執行以下操作:
double num = other_variable;
同樣,它將在C和C ++中都可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.