Human ecology
Discrete mathematics
Representations of rational numbers 1
2...
3...
Rational numbers are numbers which have the form m/n where m and n are
integers. Examples: 2/3, 22/7, 1/2, etc...
These numbers can also be expressed as decimals.
2/3 = 0.6666666...
22/7 = 3.142857142857...
1/2 = 0.5
A general decimal representation of a rational number, r, might have the form:
r = ABCD.EFGHI...
Where r = (A*(10^3)) + (B*(10^2)) + (C*(10^1)) + (D*(10^0)) + (E/(10^1))
+ (F/(10^2)) + (G/(10^3)) + (H/(10^4)) + (I/(10^5)) + ...
For representations in an arbitary base, b, a general form is:
void representation_real_and_rational_numbers();
{
real x;
rational r;
integer a[infinity];
integer b;
integer i;
// representation of a real number
x=0;
for (i=-infinity; i (less than) infinity; i++)
x=x+a[i]*b^i;
// (Unfortunately, the (less than) symbol is also the left angle bracket.
// And the left angle bracket marks the start of html tags)
//
// representation of a rational number
//
// if a real number x is also rational then
// there exists a base b for which
// there is a finite sum.
integer negative_limit;
integer positive_limit;
r=0;
for (i=negative_limit; i (less than) positive_limit+1; i++)
r=r+a[i]*b^i;
}
|
Perhaps this is a bit longer but is it more understandable?
| Conversions from... |
| Base10 to... |
Base8 |
| 0.0 |
0.0 |
| 0.1 |
0.063146314... |
| 0.2 |
0.146314631... |
| 0.3 |
0.231463146... |
| 0.4 |
0.314631463... |
| 0.5 |
0.4 |
| 0.6 |
0.463146314... |
| 0.7 |
0.546314631... |
| 0.8 |
0.631463146... |
| 0.9 |
0.714631463... |
|
| Conversions from... |
| Base8 to... |
Base10 |
| 0.0 |
0.0 |
| 0.1 |
0.125 |
| 0.2 |
0.25 |
| 0.3 |
0.375 |
| 0.4 |
0.5 |
| 0.5 |
0.675 |
| 0.6 |
0.75 |
| 0.7 |
0.875 |
|
| Conversions from... |
| Base10 to... |
Base3 |
| 0.0 |
0.0 |
| 0.1 |
0.002200220022... |
| 0.2 |
0.012101210121... |
| 0.3 |
0.022002200220... |
| 0.4 |
0.101210121012... |
| 0.5 |
0.111111111111... |
| 0.6 |
0.121012101210... |
| 0.7 |
0.200220022002... |
| 0.8 |
0.210121012101... |
| 0.9 |
0.220022002200... |
|
| Conversions from... |
| Base3 to... |
Base10 |
| 0.0 |
0.0 |
| 0.1 |
0.333333333333... |
| 0.2 |
0.666666666666... |
|
Links to other sites...
Created 30/7/99