decimal to fraction calculator Update 2017-07-29
Update 2017-07-12 change parseInt(i0*aa+addone) to parseInt(n2)+addone

<a name=decimalFraction> denominator is for() loop iteration times
decimal to fraction ; , , , , ,
=

RUN 11 ☞

Above is one input, one output. Below is many input, many output.
Box16 input ; Box16 input, Box17 output

, , RUN 22 ☞ ☜ decimal only; [ minusEqual ]
Box17 output ; RUN 23 ► ◄ text OK
control Run loop up to max. iteration. max0 default 1000000
panel answer if find accuracy zero6 default .000000
Irrational input need control panel . Rational decimal no need.
QBboxc17.value='' ; stochMat[ ] ; QBspanDrawMat.innerHTML='' ; QBspanAlert1.innerHTML=''
function decimal2fraction(arg1,arg2,arg3) ; function text0to9fraction(in0,arg2)
function doublStochMat( )





Real number calculator ;
fraction to decimal calculator
No prime code, no complex code. integer1/integer2 OK ; d2f(1/3+1/4+1/5+1/6+1/7) OK
Box81 click ex1,ex2 then click [real number calculator]

Box81 input Box82 output , , ,
Box82 ; , ,

Integer ends= ; ,
Box83 ;

QPboxc83.value='' ;
[=][=]





<a name=UnicodeSymbol>

UnicodeSymbol : ℂ ℍ ℕ ℙ ℚ ℝ ℤ ℽ ℾ ℿ ⅀ ⅅ ⅆ ⅇ ⅈ ⅉ ; × ÷ ° ◦ º ¹ ² ³
≦ ≠ ≧ < = > ± ≡ ≈ ≌ ≒ ∏ ∑ √ ∛ ∜ ∝ → ∞ ∈ ∀ ∂ ⊥ ∃ ∋ ∆ ∇ ⊿ ∟ ∠ ∫ ∬ ∭ ∮ ∥
≺ ≻ ≼ ≽ ≾ ≿ ⊀ ⊁ ≭ ≮ ≯ ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ∧ ∨ ∩ ∪ ∴ ∵ ∶ ∷ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇
Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ ΢ Σ Τ Υ Φ Χ Ψ Ω , + - * /
α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω
2017-06-20-20-44 Liu,Hsinhan access en.wikipedia.org
https://en.wikipedia.org/wiki/List_of_mathematical_symbols
en.wikipedia.org-wiki-List_of_mathematical_symbols.htm
∧,⇒,−,∖,√,≥,≤,∓,⋅,⁄,⇔,∈,ℤ,ℝ,φ,π,∑,∫, ,∮,∯,∰,…,⋯,⋮,⋰,⋱,∴,∵,≠
˜ ,∝,∞,■,□,∎,▮,‣,≈,≃,≅,♎,≒,△,≡,≜,≝,≐,↔,≪,≫,≦,≧,≺,≻,◅,▻,→,⊃,⊆
⊂,∩,ℕ,ℚ,⊇,∪,↦,•,⊧,∨,⊢,⟨,⟩,ψ,α,β,–,‖,⌊,⌉,⌋,⌈,ℂ,∗,∣,∤,∥,∦,⋕,⊥
∃,≀,↯,※,⇐,⊕,⊻,∐,′,∀,∂,∉,∌,∋,ℍ,ω,○,∘,∅,ℙ,†,⊤,—,⊗,⋉,⋊,⋈,​,ℵ,ℶ
δ,∆,⊖,Δ,ƒ,∇,∏,σ,


<a name=pictureChar>

Picture characters 册=book (phone book below public telephone) ; 目=eye ; 口=mouth ;
山= ; 川=river (bank, streamLine, bank ) ; 田=farm land with walk way ; 門=door
事=event (rope knot record events, top bar is ceiling, vertical bar is rope, two knots on rope )
日=sun ; 月=moon ; 木=tree ; 東=east (sun just rise behind tree ) ; 立=stand ; 見=look,watch
親=parents (a son stand on tree [climb high] look far away expect parents come back)
出=exit,go out (exit from home, one travel mountain after mountain) a606190148
車=car (two wheel hand-push car, top bar and bottom bar are two wheels, vertical bar axis,
middle 田 a place carry cargo. Bird view this car look like 車) ; 艸=grass,weed. a606211119
小=small (a man stand two legs touch, two arms close to legs, smaller space) a606211132
大=big (a man stand two legs wide open, two arms extend out horizontally, bigger space)
太=that is too much ; 人=human ; 巢=nest (tree 木 top nest 田 with three birds ≺≺≺ inside )
弓=bow, a shape of bow ; 引=guide , a bow and an arrow, where arrow goes is a guidance.
凸=convex,jutting ; 凹=concave,hollow ; 串=two object string together ;



<a name=LiuHH>

Liu,Hsinhan 劉鑫漢 was born 1948-02-17 in Hankow city 漢口市
Liu,Hsinhan three years old photo father09.jpg
Liu,Hsinhan seven years old photo father01.jpg
Liu,Hsinhan 22 to 35 years old photo liuhh001.jpg
Liu,Hsinhan 35 years old photo liuhh004.jpg
Liu,Hsinhan 64 years old photo liuhh007.jpg
Today Liu,Hsinhan is 70 years old, own nothing, achieve nothing.
If you like this program, then Liu,Hsinhan achieve a little bit☺
2017-06-22-20-15


<a name=document>

2017-06-23-15-10 
This file http://freeman2.com/dec2frac.htm 
is "decimal to fraction calculator" 
Following is a document introduce how code 
work. First study an example. 
Let fraction be 17/57 = 0.2982456140350877 
Assume we have decimal 0.2982456140350877 
in hand and try find out its fraction value. 
Most decimal has infinite long expression. 
decimal must be cut somewhere. Assume example 
E0=0.2982456140350877 and 
E1=0.29824561403508 and 
E2=0.29824561403509
Above slight error get very different result
0.29824561403508*57=16.99999999999956
0.29824561403509*57=17.000000000000128
'.999999' and '.000000' have different treatment.

<a name=docF002>
Program use two control parameters. 
max. iteration max0, default max0=1000000 
accuracy zero6, default value zero6='.000000'
accuracy '.000000' and accuracy '.0' are 
very different. Longer zeros '.0000000000000' 
get more accurate answer. 
We know 17/57 = 0.2982456140350877 , therefore 
if multiply 0.2982456140350877 with 2, with 3, 
..... with 56, with 57 eventually get a number 
close an integer. 
<a name=docF003>
Integer with slight error is 17.00000000000001
Integer with slight error is 16.99999999999999
If set accuracy zero6='.000000' in integer 
17.00000000000001 we find '.000000' then program 
stop multiplication loop and present answer. 
Parallel to zero6='.000000' program use another 
variable nine6='.999999'. If in integer 
16.99999999999999 we find '.999999' then program 
stop multiplication loop and present answer. 

<a name=docF004>
2017-06-23-15-49
Above in key points. Below is code document.

//change decimal 0.6888888888888889 to fraction 31/45
//arg1 is a decimal number, 
//arg2 is a maximum bound, default 1000000
//fraction numerator = arg1*i0. If arg1*i0 has 
//'.000000' or has '.999999' then find fraction.
//fraction denominator bound by maximum arg2
//If arg1*i0 has '.000000' //addone=0
//fraction=parseInt(arg1*i0)/i0
//If arg1*i0 has '.999999' //addone=1
//fraction=parseInt(arg1*i0+1)/i0
//see code line   //aa=parseFloat(arg1);
//n0=parseInt(i0*aa+addone); //a606181808 +addone
//see code line  
//return n0+'/'+i0; //a606180952
//
//addone=1 is correct, if input decimal>0 //a606191148
//

<a name=docF005>
function decimal2fraction(arg1,arg2,arg3) has three 
input arguments arg1,arg2,arg3
arg1 is decimal number in string form or in 
     number form. 
String '12' add string '34' get string '1234'
Number  12  add string '34' get string '1234'
Number  12  add number  34  get number  46
Javascript is a string dominant language. 
arg2 is maximum iteration. default 1000000
arg3 is accuracy. default 6 for '.000000'

<a name=docF006>

function decimal2fraction(arg1,arg2,arg3) //a606180930
{
var i0,j0,k0,L0,m0,n0,n1,n2,n3,n4;
if(typeof(arg1)!='string'
 &&typeof(arg1)!='number')
return 'decimal2fraction(arg1,arg2,arg3) arg1 must be a number.\n'
+'Now typeof(arg1)='+typeof(arg1)+'\n'

var aa=parseFloat(arg1);
if(isNaN(aa))return 'NaN/1'; //a607260547
<a name=docF007>
function decimal2fraction(arg1,arg2,arg3) is designed 
input one decimal (=arg1) , output one fraction. 
input decimal can be in string form and can be 
in number form. If decimal2fraction(arg1,arg2,arg3) 
receive array of string or array of number, many 
input at once? function decimal2fraction(arg1,arg2,arg3) 
reject this condition. 
Assume input is string type number, code line 
var aa=parseFloat(arg1); 
if(isNaN(aa))return 'NaN/1'; //a607260547
change string number '0.2982456140350877' to 
real number 0.2982456140350877. Input number 
has many times multiplication calculation in 
a loop code. Only real number is able to do 
the job. All input come from input box value.
<a name=docF008>
HTML box value is a string, user can input a 
"decimal" number 'aaa' . This is an error, 
click button must check this condition, if 
input box is a decimal number, call function 
decimal2fraction(arg1,arg2,arg3) to do the job. 
If input box is a Not-a-Number string 'aaa',
// red italic is button code
//blue italic is function code
if(isNaN(L0)
 ||L0.length==0
  )
QBAnsMsg1.innerHTML='Input decimal=['+QBDecimal.value+']'; 
above code stop this 'aaa' error. 
2017-06-23-16-31

<a name=docF009>
//var max0=1000000; //a606180936
//var max0=1000000000; //a606181031
//var max0=10000000; //a606181042
var max0=1000000; //a606181051
if(arguments.length>1)
  {
m0=parseInt(arg2);
if(!isNaN(m0)&&m0>=1000)max0=m0;
  }
<a name=docF010>
Convert 0.2982456140350877 to 17/57 need a 
for() loop. Loop has a bound, cannot run 
infinite many iterations. Function argument 
arg2 let source function set iteration bound.
function decimal2fraction(arg1,arg2,arg3) default 
bound is max0=1000000; Code line 
m0=parseInt(arg2); change arg2 to m0, 
if m0 is a number, and m0>=1000 then max0=m0;
'm0 is a number' same as 'm0 not_isNotaNumber' 
!isNaN(m0) here '!' represent 'not' 
isNaN('aaa') return true, !isNaN('aaa') false. 
isNaN('0.2') return false, !isNaN('0.2') true. 
Code line m0>=1000 require iteration bound is 
at least 1000, then program change bound max0 
to new value. 

<a name=docF011>
var zero6='.000000';
var nine6='.999999'; //a606192125
//a606260627 use arg3 control zero6, nine6

if(arguments.length>2) //a606260629
  {
m0=parseInt(arg3);
if(!isNaN(m0)&&m0!=6&&m0>=1&&m0<=15)
    {
n3=n4='.';
for(j0=0;j0<m0;j0++)
{ n3+='0'; n4+='9'; }
zero6=n3;
nine6=n4;
    }
  } //if(arguments.length>2) //a606260636

2017-06-26-12-38
if(arguments.length>2) say if input has three 
parameters then convert third to m0=parseInt(arg3);
If m0 is an integer not equal 6 and great equal to 
one and less equal to 15, enter process body. First 
let n3=n4='.'; next start a for() loop run m0 times, 
each loop add one '0' to n3 , add one '9' to n4. 
After loop assign new accuracy value n3 to zero6 
assign n4 to nine6 . Assume m0=8, 
zero6 change from '.000000' to '.00000000' 
nine6 change from '.999999' to '.99999999' 
2017-06-26-12-49

Yellow background code move out of function decimal2fraction(arg1,arg2,arg3). Code entered click button. Purpose let decimal2fraction() run faster. a606260955 //QBControlA.value='1000000 ' //QBControlB.value='.000000 ' if(typeof(QBControlA)=='object' &&typeof(QBControlB)=='object' &&typeof(QBspanControlA)=='object' &&typeof(QBspanControlB)=='object' )

<a name=docF012> Here check if web page has control object QBControlA and QBspanControlA QBControlB and QBspanControlB They are used in next control panel elements
control Run loop up to max. iteration. max0=1000000
panel answer if find accuracy zero6=.000000

Yellow background code move out of function decimal2fraction(arg1,arg2,arg3). Code entered click button. Purpose let decimal2fraction() run faster. a606260955 QBControlA has value '1000000' QBspanControlA has value 'max0=1000000 ' QBControlB has value '.000000' QBspanControlB has value 'zero6=.000000 ' If web page has all of these control object then enter if() body do job. <a name=docF013> dec2frac.htm function decimal2fraction(arg1,arg2,arg3) check if itself has web page object ?! Is this redundant code? Yes! it is redundant in dec2frac.htm But, someone may copy decimal2fraction(arg1,arg2,arg3) to other web page and forget copy QBspanControlA etc. In that case, this if() guard code flow go smoothly. Not read user value, use default value. If you want to include function decimal2fraction(arg1,arg2,arg3) to your web page, feel free to do so. It is better copy QBspanControlA etc. too. 2017-06-23-17-30 <a name=docF014> { //external control begin n0=parseInt(QBControlA.value); if(n0>=1000&&n0<=1.e12) { max0=n0;} Code above control for() loop maximum bound. If user set 1000<=bound<=1.e12 then change max0 to user value n0. Above QBControlA control for() loop maximum bound. Below QBControlB control answer accuracy . <a name=docF015> n1=QBControlB.value n2=n1.indexOf('.'); if(n2>=0) { for(i0=n2+1;i0<n1.length;i0++) if(n1.charAt(i0)!='0')break; //if((i0-n2)>=4&&(i0-n2)<=12) //a606231001 allow PI=22/7 if((i0-n2)>=2&&(i0-n2)<=15) { n3=n4='.'; for(j0=1;j0<(i0-n2);j0++) { n3+='0'; n4+='9'; } zero6=n3; nine6=n4; } //if((i0-n2)>=4&&(i0-n2)<=12) } //if(n2>=0) <a name=docF016> n1=QBControlB.value=string '.00000' Assume a little complicated '7.0006' n2=n1.indexOf('.'); locate '.' in n1. if user input '000000' without dot, n2=-1 -1 mean not found '.' in n1. In example '.00000' n2=0, because first byte in '.00000' is dot. In example '7.0006' n2=1 Javascript sequence start from 0, not 1. n2=1 or n2=0 satisfy if(n2>=0) condition, enter if() body. <a name=docF017> For() loop for(i0=n2+1;i0<n1.length;i0++) if(n1.charAt(i0)!='0')break; start i0 from n2+1, because n2 point to '.' n2+1 is first '0' after '.' In '7.0006' Blue 0 fail if(n1.charAt(i0)!='0') NOT break; red 0 fail if(n1.charAt(i0)!='0') NOT break; Black 0 fail if(n1.charAt(i0)!='0') NOT break; '6' satisfy if(n1.charAt(i0)!='0') OK to break; When break, i0=5 point to first none-zero '6' n2=1 point to dot '.' See string and index below string '7.0006' index 012345 2017-06-23-18-11 <a name=docF018> 2017-06-23-18-43 Next is if() code line //if((i0-n2)>=4&&(i0-n2)<=12) //a606231001 allow PI=22/7 if((i0-n2)>=2&&(i0-n2)<=15) other page http://freeman2.com/dbstochm.htm use //if((i0-n2)>=4&&(i0-n2)<=12) This page http://freeman2.com/dec2frac.htm use if((i0-n2)>=2&&(i0-n2)<=15) In example '7.0006' i0=5 point to first none-zero '6' , n2=1 point to dot '.' then i0-n2=5-1=4 This 4 indicate in '7.0006' , '.000' has four bytes. If this dot+zero string length >=2 and length <=15 then execute for() loop. <a name=docF019> n3=n4='.'; for(j0=1;j0<(i0-n2);j0++) { n3+='0'; n4+='9'; } Because (i0-n2) is dot+zero string length n3=n4='.'; already store a dot, next add zero. Code section for(j0=1; skip first byte '.' Code section for(j0=0; not skip an error. In '7.0006' , '.000' has four bytes, j0=1; skipped '.', the build of n3 and n4 is n3+='0'; n4+='9'; (i0-n2)-1 times, that is 4-1=3 times. Result is n3='.000'; n4='.999' <a name=docF020> zero6=n3; nine6=n4; zero6 and nine6 are program variables applied to fraction construction. n3 and n4 are user's will. Code line if((i0-n2)>=2&&(i0-n2)<=15) is a filter. Require 2<= dot+zero length <=15 If ignore dot Require 1<= zero length <=14 If user input '.0' to 'answer if find' box and input PI=3.141592653589793 program output 22/7. dec2frac.htm allow '.0' ; dbstochm.htm not allow. <a name=docF021> QBspanControlA.innerHTML='max0='+max0; QBspanControlB.innerHTML='zero6='+zero6; //a606192211 //external control end } //if(typeof(QBControlA)=='object' // &&typeof(QBControlB)=='object') Above code line print program accepted variable values max0 and zero6 to web page below Box17. Yellow background code move out of function decimal2fraction(arg1,arg2,arg3). Code entered click button. Purpose let decimal2fraction() run faster. a606260955

Above is data collection, preparation. Below is decimal to fraction code. <a name=docF022> var bb,ans0; var addone=0; //a606181806 At beginning of function decimal2fraction(arg1,arg2,arg3) defined var aa=parseFloat(arg1); if(isNaN(aa))return 'NaN/1'; //a607260547 aa is input decimal in real number. Variable aa is OK to participate in calculation. Variable bb is i0*aa and convert to string. i0 is variable in for(i0=2;i0<max0;i0++) Variable addone adjust fraction numerator value. Why need addone ? See next example <a name=docF023> If decimal in hand is 0.0754716981132076=4/53 for(i0=2;i0<max0;i0++) loop multiply 0.0754716981132076 with 2,3,4,5 ... until 53 2 * 0.0754716981132076=0.1509433962264152 3 * 0.0754716981132076=0.2264150943396228 ..... 50 * 0.0754716981132076=3.77358490566038 51 * 0.0754716981132076=3.8490566037735876 52 * 0.0754716981132076=3.924528301886795 53 * 0.0754716981132076=4.000000000000003 The product 4.000000000000003 has '.000000' Then find answer, denominator is i0=53 numerator is i0*aa=4.000000000000003 Fraction answer must be integer1/integer2 Code line n0=parseInt(i0*aa+addone); change 4.000000000000003 to 4. Answer is 4/53 In this case addone=0 <a name=docF024> If decimal is 0.766385302879841=3087/4028 for(i0=2;i0<max0;i0++) loop multiply 4026 * 0.766385302879841=3085.46722939424 4027 * 0.766385302879841=3086.2336146971197 4028 * 0.766385302879841=3086.9999999999995 The product 3086.9999999999995 has '.999999' Then find answer, denominator is i0=4028 numerator is i0*aa=3086.9999999999995 Fraction answer must be integer1/integer2 Code line n0=parseInt(i0*aa+addone); change 3086.9999999999995 to 3087 Answer is 3087/4028 In this case addone=1 If addone=1 then parseInt(3086.9999999999995+1) get numerator=3087 correct! If addone=0 then parseInt(3086.9999999999995) get numerator=3086 error! <a name=docF025> If decimal in hand is + or - and product has '.000000' set addone=0 for correct answer. If decimal in hand is positive and product has '.999999' set addone=1 for correct answer. If decimal in hand is negative and product has '.999999' set addone=-1 for correct answer. 2017-06-23-20-08 <a name=docF026> 2017-06-23-20-55 for(i0=2;i0<max0;i0++) { k0=i0*aa; bb=k0+''; //if(bb.indexOf('.000000')>0)break; //a606192126 if(bb.indexOf(zero6)>0)break; //a606191151 if(aa<0)addone=-1; a tricky error //if(bb.indexOf('.999999')>0) //a606192127 if(bb.indexOf(nine6)>0) { if(aa>=0)addone=1;else addone=-1; break; } if(k0==parseInt(k0))break; //a606180950 } //for(i0=2;i0<max0;i0++) <a name=docF027> In for(i0=2;i0<max0;i0++) i0 will be answer fraction denominator value. i0 must start from 2. Because 17/1 or 17/0 both are not answer. Code i0<max0 or i0<1000000 this is force to stop if input is an irrational k0=i0*aa; is a real number 3086.9999999999995 bb=k0+''; is a string '3086.9999999999995' In a real number one cannot search '.999999' In a string it is allowed to search '.999999' <a name=docF028> There are three breaks. if(bb.indexOf(zero6)>0)break; Variable zero6='.000000' bb=k0+''; is a string '4.000000000000003' In '4.000000000000003' search for '.000000' success, break from for(i0=2;i0<max0;i0++) Not need set addone=0. Because default is zero. <a name=docF029> if(bb.indexOf(nine6)>0) { if(aa>=0)addone=1;else addone=-1; break; } Variable nine6='.999999' bb=k0+''; is a string '3086.9999999999995' In '3086.9999999999995' search for '.999999' success, break from for(i0=2;i0<max0;i0++) Must set addone=1 or -1. Because addone=0 . parseInt( 3086.9999999999995+1) get 3087 parseInt(-3086.9999999999995-1) get -3087 <a name=docF030> 4.000000000000003 not=4=parseInt(4.000000000000003) but in case i0*aa=5*0.2=1 exactly, string '1' no '.000000', no '.999999' But integer 1 has 1=1=parseInt(1) In this case if(k0==parseInt(k0))break; //a606180950 stop for() loop. <a name=docF031> //next is faster code no if(), no indexOf() n0=parseInt(i0*aa+addone); //a606181808 +addone n1=bb.indexOf('.'); //a607121258 if(n1>=0) n2=bb.substring(0,n1); else n2=bb; //a607121319 if() else n0=parseInt(n2)+addone; //a607121259 return n0+'/'+i0; //a606180952 } //function decimal2fraction(arg1) Code line n0=parseInt(i0*aa+addone); change 4.000000000000003 to 4 change 3087.9999999999995 to 3087 change -3087.999999999999 to -3087 n0 is numerator, i0 is denominator. Division '/' is a string. Number n0 + string '/' + number i0 get a string '4/53'. Code line return n0+'/'+i0; send answer back. 2017-06-23-21-30 <a name=docF031b> 2017-07-12-13-29 Build-in function parseInt() has next two answers. parseInt(1.9999999999999997)=1 parseInt(1.99999999999999997)=2 n0=parseInt(i0*aa+addone) OK //addone=1 n0=parseInt(i0*aa+addone) ERROR ! Blue code use addone help, red code use addone damage answer. 2017-07-12-12-55 use next code lines n1=bb.indexOf('.'); //a607121258 if(n1>=0) n2=bb.substring(0,n1); else n2=bb; //a607121319 if() else n0=parseInt(n2)+addone; //a607121259 avoid above error. If user input 0.0754716981132076 after 0.0754716981132076*53 find result 4.000000000000003 a607121258 code line in '4.000000000000003' find '.' location. a607121319 if() else code lines extract '4' from '4.000000000000003' a607121259 code line change string '4' to number 4. return n0+'/'+i0; send '4/53' back as answer. 2017-07-12-13-42 <a name=docF032> Liu,HsinHan is not a professional programmer. Above code is not efficient. If reader know computer language, you are welcome re-write and improve efficiency. You can use this code anywhere, not need ask LiuHH yes/no. The answer is always "OK, you can use Liu,Hsinhan code in your application." 2017-06-23-21-36 <a name=docF033> 2017-06-24-08-48 If reader ask "How to apply function decimal2fraction(arg1,arg2,arg3) in application?" Please visit doubly stochastic matrix calculator http://freeman2.com/dbstochm.htm In control checkbox 0.688... decimal if user uncheck 0.688... decimal program output
4
3
3
3
2
=
0.5625 0.0625 0 0.125 0.25
0 0.6666666666666666 0 0.3333333333333333 0
0 0 1 0 0
0.25 0.25 0 0.5 0
0.1875 0.020833333333333332 0 0.041666666666666664 0.75
*
6
4
3
1
1
Doubly stochastic matrix table is created by http://freeman2.com/dbstochm.htm
doublStochMat() Date/Time: 2017-06-24-08-58-08.605, elapse=0.005 sec.
if user check 31 / 45 fraction program output
4
3
3
3
2
=
9/16 1/16 0/2 1/8 1/4
0/2 2/3 0/2 1/3 0/2
0/2 0/2 2/2 0/2 0/2
1/4 1/4 0/2 1/2 0/2
3/16 1/48 0/2 1/24 3/4
*
6
4
3
1
1
Doubly stochastic matrix table is created by http://freeman2.com/dbstochm.htm
doublStochMat() Date/Time: 2017-06-24-09-00-42.386, elapse=0.024 sec.
<a name=docF034> Open http://freeman2.com/dbstochm.htm with notepad.exe and find next code. //doubly stochastic matrix function doublStochMat( //a606120748 aStr //define alpha sequence, more average , bStr //define beta sequence, more diverse ) { //9906172025 start stochastic0() //a606120748 start doublStochMat() ..... //<a name=docF035> if(typeof(QBfraction)=='object' &&QBfraction.checked &&typeof(decimal2fraction)=='function' ) { for(i0=0;i0<stochMat.length;i0++) for(j0=0;j0<stochMat.length;j0++) stochMat[i0][j0]=decimal2fraction(stochMat[i0][j0]); //a606181625 fraction output OK } //if(typeof(QBfraction)='object'&&QBfraction.checked) return stochMat; //9906191748; a606121622; a606181626 } //function doublStochMat() //a606162016 Above bold italic blue is the key step convert from decimal to fraction. Follow this code and write similar code in your application. 2017-06-24-09-23 <a name=docF036> Update 2017-06-27 2017-06-27-09-02 Below Box16, it has one line look like next RUN 22 ☞ ☜ decimal only; [ minusEqual ] What is "minusEqual" ? minusEqual box let user input '-' or '='. If delete box value, the default value is ' - '. After fill value, click [decimal2fraction()] button code read minusEqual box value and show up in Box17 output. If input '-' (default value) output 3087/4028 - 0.766385302879841 <a name=docF037> User copy and paste this line to Box81 and click output to Box82 [[ 3087/4028 - 0.766385302879841 1.1102230246251565e-16 ]] confirm 3087/4028 and 0.766385302879841 are same value (error 1.1102230246251565e-16) On the other hand, if input '=' to minusEqual box. Click [decimal2fraction()] button, in Box17 output 3087/4028 = 0.766385302879841 This is regular output. 2017-06-27-09-16 <a name=docF038> 2017-06-27-10-05 Ten minutes ago, modified button code in Key strings are 'a6062709' and 'minusE2' If Box16 input has negative value -0.05109235352532273 Box17 output -1029/20140 - -0.05109235352532273 cannot give answer. If minusEqual box has string '-(', code assign minusE2=')' and output -1029/20140 - ( -0.05109235352532273 ) This line can get answer. 2017-06-27-10-12 <a name=docF039> 2017-07-11-16-05 Update 2017-07-12 added button indicate that in dec2frac.htm it is possible write next code line [[ cc=decimal2fraction(1/3+1/4+1/5+1/6+1/7) cc // print cc value 153/140 -(1/3+1/4+1/5+1/6+1/7) //confirm ]] fraction sum input and fraction output. Other calculator prime_e3.htm , complex4.htm do not have function decimal2fraction() then other calculator cannot do the same job. 2017-07-11-16-13 <a name=docF040> 2017-07-11-19-33 Just added function d2f() //a607111927 as a short hand for decimal2fraction(arguments[0]); In Real number calculator call cc=d2f(1/3+1/4+1/5+1/6+1/7) it has same effect as cc=decimal2fraction(1/3+1/4+1/5+1/6+1/7) input function name much shorter. 2017-07-11-19-38 <a name=docF041> 2017-07-16-11-52 Update 2017-07-16 follow Chinese version doubly stochastic matrix calculator upload to http://freeman2.com/dbstoch1.htm and made minor change to dec2frac.htm Please pay attention on the following files doubly stochastic matrix calculator http://freeman2.com/dbstochm.htm English http://freeman2.com/dbstoch1.htm Chinese decimal to fraction calculator http://freeman2.com/dec2frac.htm English http://freeman2.com/dec2frak.htm Chinese Above four files all deleted error code and use correct code. But next file doubly stochastic matrix calculator debug version http://freeman2.com/dbstochn.htm English keep error code on purpose. Let user compare the correct with error. For your application please download correct version. Liu,Hsinhan 2017-07-16-12-01 <a name=docF042> 2017-07-27-18-10 Update 2017-07-27 change function bye09() error. error code line change to new a607211645 line. //if(nine0<0)nine0--; // negative integer minus one if(in09<0)nine0--; //a607211645 After correction, program change -0.99999999999 to -1 . (Error code change to +1) 2017-07-27-18-13 <a name=docF043> 2017-07-29-15-09 Update 2017-07-29 change a mountain picture 山=∆∆ in pictureChar section. See more at http://freeman2.com/numjsdoc.htm#base64learn and numjsdoc.htm#docA008 2017-07-29-15-15 [=][][]


<a name=JavascriptIndex>
Javascript index
http://freeman2.com/jsindex2.htm   local
Save graph code to same folder as htm files.
http://freeman2.com/jsgraph2.js   local




decimal to fraction calculator was part of
doubly stochastic matrix calculator
http://freeman2.com/dbstochm.htm
dbstochm.htm first Upload 2017-06-13
(related material see tute0047.htm)


decimal to fraction calculator Chinese version
http://freeman2.com/dec2frak.htm

decimal to fraction calculator
http://freeman2.com/dec2frac.htm
First Upload 2017-06-24
Thank you for visiting Freeman's page. 
Freeman Liu,Hsinhan 劉鑫漢 2017-06-22-18-06