Quantcast
Viewing all articles
Browse latest Browse all 2935

Problem with converting a floating-point value into a long value

Hi,

 

i encountert a problem with the conversion of a floating-point value into a simple long value. It seems like it only works correct with a decimal value as well as a constant.

 

eg.

 

long ( 99.8 ) = 100

which is totally fine,but the following seems wrong to me

 

DOUBLE ldbl_value = 99.8

 

 

long ( ldbl_value ) = 99

Why do i get a different result with that code?

 

What do you think of that?

 

 

I enclosed an image of a list, which showes how the conversion is creating different results, depending on the input type.

 

Best Regards

TimKp


Viewing all articles
Browse latest Browse all 2935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>