Thread: how to approach this
i'm intermediate programmer (just fun here , there) , wondering how go writing program (approximately) reduces fraction came decimal.
lets start decimal 0.82931. change 82931/100000. however, need fraction denominator <= 6. therefore i'd somehow need reduce 4/5. should ignore after 1st decimal place? or there better way it.
hi,
don't know if there better way, here mine.
since have limited number of denominators select (2, 3, 4, 5, 6),
following:
assuming number want convert x
- each denominator n=2,3,4,5,6 compute an=x-int(x*n)/n;
- select n gives minimum an
- compute approxx=int(x*n)/n;
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk how to approach this
Ubuntu
Comments
Post a Comment