Jump to content

Talk:Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions

m
no edit summary
mNo edit summary
Line 11:
: This depends on the definition of the canonical form for negative numbers. 151/77 is [1;1,24,1,2] so the negative form [-1;-1,-24,-1,-2] seems clearer to me. [[Continued_fraction/Arithmetic/Construct_from_rational_number]] defines how to construct continued fractions thus determine: the integer part; and remainder part, of N<sub>1</sub> divided by N<sub>2</sub>. It then sets N<sub>1</sub> to N<sub>2</sub> and N<sub>2</sub> to the determined remainder part. It then outputs the determined integer part. It does this until abs(N<sub>2</sub>) is zero. Here N<sub>1</sub> is -151 and N<sub>2</sub> is 77. -151/77 is -1 remainder -74. Wikis seem to define the canaonical form as [a<sub>0</sub>;a<sub>i</sub>,...,a<sub>j</sub>] where a<sub>0</sub> is an integer and a<sub>i</sub>,...,a<sub>j</sub> are positive integers. [http://www.andrewduncan.ws/goldenratio/continuedfractions/index.html] gives [-2 ; 25,1,2,1705908949761,1,1,4,2,1,4,1,23…] so your version has some support, but if we adopt it then Mathmatica will have to be rewritten and I think the form which makes the negative form similar to the positive form is better.--[[User:Nigel Galloway|Nigel Galloway]] 13:36, 11 March 2013 (UTC)
 
::Right, but the problem is that there are (at least) two different definitions of division / remainder for negative numbers. For example, in C99/Java, (-151) / 77 is -1 and (-151) % 77 is -74, but in Python/Ruby, (-151) / 77 is -2 and (-151) % 77 is 3. --[[User:Spoon!|Spoon!]] 20:27, 11 March 2013 (UTC)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.