Fractions in C++? 09-13-2011, 02:49 AM
#1
I was writing a primitive program involving solving a random equation, and I noticed that when I entered:
long double y;
y = (1/5) + (2/8);
cout << y
The computer could not read the fractions, and it only worked when I changed it to decimals. Is there any way to use fractions in C++, or is it limited to significant figures?
long double y;
y = (1/5) + (2/8);
cout << y
The computer could not read the fractions, and it only worked when I changed it to decimals. Is there any way to use fractions in C++, or is it limited to significant figures?

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)


![[Image: mrawesome.gif]](http://i1022.photobucket.com/albums/af347/shivammehta007/mrawesome.gif)