## How to determine if string from file is float or double in C++?

I would like to parse a file and determine if the number I've read is float or double. The file I parse is one of the matrices in Matrix Market format (like this: https://sparse.tamu.edu/HB/1138_bus).

## Why does printf(“%.2f”, (double) 12.555) return 12.55?

I was writing a program where I had to round double to second decimal place. I noticed printf("%.2f", (double) 12.555) return 12.55. However, printf("%.2f", (float) 12.555) returns 12.56. Can anyone explain why this happens?

## why result of (double + int) is 0 (C language)

result ofprintf("%d/n", 5.0 + 2);is 0butis 7What's the difference between the two?The result of 5.0 + 2 is 7.0 and is of type double.

## Checking if a double is equal to -0.00

I am making this big program in C, which is a part of my homework. My problem is that my program is outputing x = -0.00 instead of x = 0.00. I have tried comparing like if(x==-0.00) x=fabs(x) but I've read that it won't work like that with doubles. So...

## Why is decimal more precise than double if it has a shorter range? C#

Im reading the C# in a Nutshell book and it shows this table: Im having a hard time understanding the table. It says that double takes 64 bits of space and it ranges from 10^-324 to 10^308. Decimal takes 128 bits of space BUT is also says that it ranges...

## Best way to approximate in direction to zero in C++

I have some troubles explaining clearly but it's rather simple.. I have a double named value in my C++ program and I want to Floor it if it's a positive value and Ceil if it's a negative value, the precision is given by an external variable.

## Convert double to int array

I have a double I want to convert this to a int arrayI came up with thisIt's working but I don't like this solution because I think a lot of conversions between datatypes can lead to errors. Is my code even complete or do I need to check for something...

## Java – Convert double to int array

I have a double I want to convert this to a int arrayI came up with thisIt's working but I don't like this solution because I think a lot of conversions between datatypes can lead to errors. Is my code even complete or do I need to check for something...