{"id":1120,"date":"2012-07-14T11:55:07","date_gmt":"2012-07-14T17:55:07","guid":{"rendered":"http:\/\/bateru.com\/news\/?p=1120"},"modified":"2012-07-14T12:41:25","modified_gmt":"2012-07-14T18:41:25","slug":"how-to-convert-repeating-decimal-to-a-fraction","status":"publish","type":"post","link":"https:\/\/bateru.com\/news\/2012\/07\/how-to-convert-repeating-decimal-to-a-fraction\/","title":{"rendered":"How to convert a repeating decimal to a fraction"},"content":{"rendered":"<p><a href=\"http:\/\/www.flickr.com\/photos\/nicmcphee\/4511498998\/\"><img decoding=\"async\" src=\"http:\/\/farm3.staticflickr.com\/2322\/4511498998_a0d12a3a0e.jpg\"\/><\/a><br \/>\nHere are 4 simple steps to convert a repeating decimal to a fraction.<\/p>\n<p><b>Step 1:<\/b> Check to see if the number has a repeating decimal. Stop if it doesn&#8217;t and do normal conversion.<\/p>\n<p><b>Step 2:<\/b> Split the decimal into 3 parts; i, x, r. Such that the decimal equals `i.x(r)*`.<\/p>\n<p><b>Step 3:<\/b> Create a fraction in the form `a\/b`.<br \/>\na = ((ixr as int) &#8211; (ix as int))<br \/>\nb = ((10^<sup>x.length<\/sup>)*(10^<sup>r.length<\/sup> &#8211; 1))<\/p>\n<p><b>Step 4:<\/b> (optional) Reduce the fraction by dividing by the greatest common denominator.<\/p>\n<p><b>Example:<\/b><br \/>\n4\/3 = 1.333&#8230; which sets i = &#8220;1&#8221;, x = &#8220;&#8221;, r = &#8220;3&#8221;.<br \/>\na = (13 &#8211; 1) = 12, b = ((10^<sup>0<\/sup>)*(10^<sup>1<\/sup> &#8211; 1)) = 9<br \/>\na\/b = 12 \/ 9 = 4\/3<\/p>\n<p><a href=\"https:\/\/github.com\/LarryBattle\/Ratio.js\/\">Ratio.js<\/a> does this for you when the `reduce` function is called.<\/p>\n<p><\/b>Example using Ratio.js:<\/b><br \/>\n<code><\/p>\n<pre lang='javascript'>\r\nRatio.parse( \"1\/3\" ).reduce().toString() === \"1\/3\";\r\nRatio.parse( 4\/3 ).reduce().toString() === \"4\/3\";\r\nRatio.parse( 0.123451234512345 ).reduce().toString() === \"4115\/33333\";\r\nRatio.parse( 0.987987989798979897 ).reduce().toString() === \"978108109901\/990000000000\";\r\n<\/pre>\n<p><\/code><\/p>\n<h2><a href=\"http:\/\/jsfiddle.net\/jL8MN\/1\/\">DEMO<\/a><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Here are 4 simple steps to convert a repeating decimal to a fraction. Step 1: Check to see if the number has a repeating decimal. Stop if it doesn&#8217;t and do normal conversion. Step 2: Split the decimal into 3 parts; i, x, r. Such that the decimal equals `i.x(r)*`. Step 3: Create a fraction &hellip; <a href=\"https:\/\/bateru.com\/news\/2012\/07\/how-to-convert-repeating-decimal-to-a-fraction\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to convert a repeating decimal to a fraction<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,23,10],"tags":[164,166,147,16],"class_list":["post-1120","post","type-post","status-publish","format-standard","hentry","category-frontend-tech","category-math","category-tutorials","tag-javascript","tag-math","tag-ratio-js","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/1120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/comments?post=1120"}],"version-history":[{"count":11,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/1120\/revisions"}],"predecessor-version":[{"id":1130,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/1120\/revisions\/1130"}],"wp:attachment":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/media?parent=1120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/categories?post=1120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/tags?post=1120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}