Does anybody have a script to simplify fractions? 8 4544
Or just like a recommendation? mo********@gmai l.com wrote: Or just like a recommendation?
What exactly do you need? Please provide sample input/output... mo********@gmai l.com wrote: Does anybody have a script to simplify fractions?
To simplify a fraction, find the greatest common divisor of the numerator
and the denominator of the fraction and divide both by it if there is one
greater than 1.
<URL:http://google.com/search?q=simpli fy+fraction&fil ter=0>
HTH
PointedEars
JRS: In article <11************ **********@g14g 2000cwa.googleg roups.com>
, dated Thu, 12 Jan 2006 17:52:27 local, seen in
news:comp.lang. javascript, mo********@gmai l.com <mo********@gma il.com>
posted : Does anybody have a script to simplify fractions?
Let the fraction be X/Y, X & Y being variables.
function HCF(u, v) { var U = u, V = v
while (true) {
if (!(U%=V)) return V
if (!(V%=U)) return U } }
T = HCF(X, Y) ; X /= T ; Y /= T ;
HCF is used in jsdates.htm, via FAQ, see below. It is intended for use
only with positive integer parameters, but full compliance is not
obligatory.

© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/jsindex.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dr John Stockton said the following on 1/13/2006 3:03 PM: JRS: In article <11************ **********@g14g 2000cwa.googleg roups.com> , dated Thu, 12 Jan 2006 17:52:27 local, seen in news:comp.lang. javascript, mo********@gmai l.com <mo********@gma il.com> posted :
Does anybody have a script to simplify fractions?
Let the fraction be X/Y, X & Y being variables.
function HCF(u, v) { var U = u, V = v
Just for my own curiosity, does the U = u and V = v serve any useful
purpose? Meaning, does the code fail if you use u and v below instead of
U and V?
It shouldn't is why I am asking.
while (true) { if (!(U%=V)) return V if (!(V%=U)) return U } }
T = HCF(X, Y) ; X /= T ; Y /= T ;
HCF is used in jsdates.htm, via FAQ, see below. It is intended for use only with positive integer parameters, but full compliance is not obligatory.

Randy
comp.lang.javas cript FAQ  http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices  http://www.JavascriptToolbox.com/bestpractices/
Randy Webb <Hi************ @aol.com> writes: Dr John Stockton said the following on 1/13/2006 3:03 PM: function HCF(u, v) { var U = u, V = v
Just for my own curiosity, does the U = u and V = v serve any useful purpose? Meaning, does the code fail if you use u and v below instead of U and V?
Not in this case. Both "u" and "U" are local variables, and since "u"
is never used again, there is no immediate need to rename it.
I'm guessing it's a general strategy to avoid changing the parameters,
in case they are needed again later.
/L

Lasse Reichstein Nielsen  lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
JRS: In article <W6************ ********@comcas t.com>, dated Fri, 13 Jan
2006 21:38:20 local, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted : Dr John Stockton said the following on 1/13/2006 3:03 PM: Let the fraction be X/Y, X & Y being variables.
function HCF(u, v) { var U = u, V = v
Just for my own curiosity, does the U = u and V = v serve any useful purpose? Meaning, does the code fail if you use u and v below instead of U and V?
It shouldn't is why I am asking.
while (true) { if (!(U%=V)) return V if (!(V%=U)) return U } }
T = HCF(X, Y) ; X /= T ; Y /= T ;
HCF is used in jsdates.htm, via FAQ, see below. It is intended for use only with positive integer parameters, but full compliance is not obligatory.
Usually at least, ISTM that it will not fail. I converted it from
another language, in which there are three possible ways of passing
parameters and the one which copies must be used (another won't compile
with that body; the third will change the external quantities). I put
the copying in as being easier than deciding whether it might ever
matter.
The only javascript in which I at present use it is
F = A[0] ; J = N ; while (J) F = HCF(F, A[J])
after which A is abandoned and F is displayed  so I'd not notice the
difference anyway even if there were any.
Code, in jsdates.htm, changed. Thanks.
<URL:http://www.merlyn.demo n.co.uk/hcfactor.pas> has several HCF
algorithms.

© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/>  FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics 
by: selowitch 
last post by:
I've been searching in vain for a way to present typographically
correct fractions (not resorting to <sup> and <sub> tags) but have been
frustrated by the fact that the glyphs for onehalf, oneeighth,
threequarters, etc. do not display in the correct typeface (or even
consistently the same typeface) and seem totally resistant to attempt
to...

by: Steffen 
last post by:
Hi,
is it possible to have two fractions, which (mathematically) have the
order a/b < c/d (a,b,c,d integers), but when (correctly) converted into
floating point representation just have the opposite order?
The idea is that the two fractions are almost identical and that the
error introduced by going to floating point representation is...

by: Mori 
last post by:
Hi,
Can someone supply a code example of displaying a string with a fractional
part, say 5 and 7 16ths.
I cannot find an example of how to use the Encoding object (if that is what
you use).
thanks,
Mori

by: Cogito 
last post by:
I'm trying to understand some Javascript code from a certain site.
Could you please tell me what does this test mean?
if ( j%4 == 0 )
What does %4 test for and is there a web site that explains it and,
presumably, also %1, %2 etc.

by: Bob 
last post by:
Hi All,
Was wondering if in C# there is an elegant way of displaying and or calculating
fractions.
The case: we have an app that measures/slices dices etc and all our internal
measures and counters are in metric measures ... (its a manufacturing tool)
For display purposes this is fine for Australia/Europe/Asia .. however
the US company...
 
by: Semajthewise 
last post by:
Here it is cleaned up a little more.
Here's what this code does. It will take 2 fractions and add, subtract, multiply, or divide them. The user enters the fractions to be calculated into two textboxes. These can be entered as a whole number and a proper fraction, whole number and an improper fraction, just a proper/inproper fraction, or just a...

by: gubbachchi 
last post by:
Hi all,
How to convert the fractions into decimals and vice versa in php.
I have a form, where the user will enter fractions in the text boxes such as "1 1/2", "1 1/4" and so on. I need to store all these values in mysql database after converting it into decimal value, and again fetch the value from database and reconvert it into fractions...

by: Paddy 
last post by:
(From: http://paddy3118.blogspot.com/2008/09/pythonfractionsissue.html)
There seems to be a problem/difference in calculating with the new
fractions module when comparing Python 26rc2 and 30rc1
I was reading the paper "Interval Arithmetic: Python Implementation
and Applications" and thought to try the first example function
f(x,y),...

by: jinu1996 
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...

by: agi2029 
last post by:
Let's talk about the concept of autonomous AI software engineers and nocode agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...

by: isladogs 
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
 
by: conductexam 
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...

by: TSSRALBI 
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LANtoLAN VPNs.
The last exercise I practiced was to create a LANtoLAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...

by: adsilva 
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

by: 6302768590 
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

by: muto222 
last post by:
How can i add a mobile payment intergratation into php mysql website.

by: bsmnconsultancy 
last post by:
In today's digital era, a welldesigned website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
 