How to Convert Fraction to Decimal: 3/8

  • Thread starter Poweranimals
  • Start date
  • Tags
    Fraction
In summary, the conversation discusses the best way to convert a fraction into a decimal, with a suggested pseudo program provided. The program involves setting a whole number and array elements, and using a real number to determine the decimal. The conversation also mentions the use of long division and the limitations of computer precision in representing fractions as decimals. The conversation ends with the mention of using an algorithm to compute decimal representations for fractions with a large number of digits.
  • #1
Poweranimals
68
0
What is the best way to convert a fraction into a decimal. IE: 3/8?
 
Mathematics news on Phys.org
  • #2
Maybe you could devise a pseudo program.

Let a < b. To convert a/b to a decimal:

Line 1: Set the whole number m = 1.
Line 2: Set the array element n[m] = 9.
Line 3: Set the real number x = b*n[m] - a*10m.
Line 4: If x > 0, then decrement n[m] and go back to Line 3. Otherwise, set a = -x, b = b*10m, increment m, and go back to Line 2.

The decimal is 0.n[1]n[2]n[3]n[4]n[5]...

That is, the decimal is a "0." followed by the juxtaposition of the array elements of n[.] in ascending order.

OK, I think I got that pseudo program to make sense now.



Following the program for 3/8:

m = 1
n[1] = 9
x = 8*9 - 3*101 = 42
:
:
eventually, n[1] = 3
x = 8*3 - 3*101 = -6
a = 6
b = 8*101 = 80
m = 2
n[2] = 9
x = 80*9 - 6*102 = 120
:
:
eventually, n[2] = 7
x = 80*7 - 6*102 = -40
a = 40
b = 80*102 = 8000
m = 3
n[3] = 9
x = 8000*9 - 40*103 = 32000
:
:
eventually, n[3] = 5
x = 8000*5 - 40*103 = 0
a = 0
b = 8000*103 = 8E6
m = 4
n[4] = 9
x = 8E6*9 - 0*104 = 7.2E7
:
:
which obviously will yield a zero for every other digit found

This procedure has given:
n[1] = 3, n[2] = 7, n[3] = 5, n[m>3] = 0
in accordance with the calculator.
 
Last edited:
  • #3
The easiest way is to just long divide until you start getting 0's or you satisfy the number of digits you need.

cookiemonster
 
  • #4
cookiemonster said:
The easiest way is to just long divide until you start getting 0's or you satisfy the number of digits you need.

cookiemonster

I'm with cookiemonster on this one. You should be able to spot a pattern if you start repeating.
 
  • #5
I was under the impression (though I wouldn't be surprised to be mistaken) that division would be an undesirable feature.
 
  • #6
Yeah, I can see that. If division is not an option, your program may be a viable option.
 
  • #7
ophecleide said:
Yeah, I can see that. If division is not an option, your program may be a viable option.

In many cases the computers approximation to the correct result may not be desirable. Consider what happens if the rational number results in a repeating pattern which is not fully developed within the precision of your software? You need some method of computing digits unconstrained by the computers word length. Windows generates about 15 decimal digits so any fraction which requires more digits then this cannot be precisely computed by windows. I once created an Excel spreadsheet which generated decimal representation of a fraction to however many digits you wanted. Unfortunately, as I sit typing this, I cannot recall the algorithm I used. May have been very similar to that presented by Turin.

BTW, I believe that an application of the Pigeon Hole principle revels that the magnitude of the denominator gives the maximum possible number of digits in the decimal representation. (That is number of digits in which the result must terminate or being repeating.
 
  • #8
Integral said:
Windows generates about 15 decimal digits so any fraction which requires more digits then this cannot be precisely computed by windows.

It's not a Windows restriction, it's C/C++ restriction. If you want a variable to have more than 15 digits, it has to be an array (which would be incredibly hard on memory). Here is a table of C++ variable types.
http://myfiles.dyndns.org/datasheets/comp_variable_types.jpg
 
Last edited by a moderator:
  • #9
Matlab liked my program. I put it in an m-file and ran it just for kicks. You can set the maximum m value to whatever you want. I think the program should be modified to truncate the excessive amount of traling zeros that one would incur for large numbers of decimal places (using my algorithm).
 

1. What is the easiest way to convert 3/8 to a decimal?

The easiest way to convert a fraction to a decimal is to divide the numerator (top number) by the denominator (bottom number). In this case, 3 divided by 8 is equal to 0.375.

2. Can I use a calculator to convert 3/8 to a decimal?

Yes, you can use a calculator to convert fractions to decimals. Simply enter 3 divided by 8 and the calculator will display the decimal equivalent, which is 0.375.

3. Are there any tricks or shortcuts to convert fractions to decimals?

One trick to convert fractions to decimals is to remember that the decimal point in a fraction is located directly below the division line. So, in 3/8, the decimal point would be placed after the 3, making it 0.375. Another trick is to convert the fraction to a percentage by multiplying the fraction by 100, and then moving the decimal point two places to the left. In this case, 3/8 would become 37.5%, which is the same as 0.375 in decimal form.

4. How do I know if my answer is correct when converting fractions to decimals?

You can double check your answer by converting the decimal back to a fraction. To do this, count the number of decimal places and use that number as the denominator. For example, 0.375 has three decimal places, so the fraction would be 375/1000. Then, simplify the fraction to get the final answer of 3/8.

5. Can fractions be converted to decimals with numbers that have repeating decimal points?

Yes, fractions with repeating decimal points can be converted to decimals. For example, 1/3 can be written as 0.333... where the 3 repeats infinitely. It is important to note that these decimals cannot be simplified to a fraction, so they are often written with a line or dot over the repeating digit(s). In this case, 1/3 would be written as 0.3̅ or 0.3⋅.

Similar threads

Replies
7
Views
163
  • General Math
Replies
2
Views
1K
  • General Math
Replies
1
Views
1K
  • General Math
Replies
3
Views
3K
Replies
9
Views
2K
Replies
3
Views
2K
Replies
8
Views
7K
Replies
12
Views
1K
Replies
4
Views
415
Replies
6
Views
2K
Back
Top