简体   繁体   中英

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. I need a syntax in c OR C++ for that?

Do you have your number saved as a string? If yes do (this will work in both C and 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:

double num = other_variable;

Again, it will work in both C and C++.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM