Aliya,

Pardon, but I didn't understand why rational numbers solely?

C/C++ treats non-integer rational numbers (a/b, where a and b are integers
and b!=0, like 1./2, 23./526, 526./23, etc.) and irrational numbers (not
a/b, where a and b integers and b!=0, like e, pi, Neperian logarithm of 2,
3, etc., square root of 2, 3, etc.) alike.

The notation 1., 23., 526. above is to tell the compiler to treat them not
as integers or whole numbers, but as floating-point numbers (at least a or b
should be written this way).

They are of 3 types, AFAIK: float, double and long double, differentiating
by their precision (number of decimal places).

Despite having decimal places (you may also call them floating-point
numbers), they are arithmetic types first, undergoing the same basic (+, -,
*, /) operations as for integers.

Mind that I didn't mention the % (modulus/remainder) operator, exclusive of
the integers.

Examples:

float f = sqrt(2);
double d = sqrt(2);
long double ld = sqrt(2);

cout << sizeof(f) << " bytes: " << setprecision(12) << f << endl;
cout << sizeof(d) << " bytes: " << setprecision(12) << d << endl;
cout << sizeof(ld) << " bytes: " << setprecision(12) << ld << endl;

My machine yields:

4 bytes: 1.41421353817
8 bytes: 1.41421356237
12 bytes: 1.41421356237

Best,

Geraldo


----- Original Message ----- 
From: "aliya_farooq24" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, October 25, 2008 8:31 AM
Subject: [c-prog] help required plz!!!!


> hi every one !
> i need some help about the progrrame dealing with rational numbers
> performing all arithmetic operations. plz help me!
>
>
> ------------------------------------
>
> To unsubscribe, send a blank message to
> <mailto:[EMAIL PROTECTED]>.Yahoo! Groups Links
>
>
>
>
>


Reply via email to