Talk:Arithmetic/Rational: Difference between revisions

From Rosetta Code
Content added Content deleted
(Computer numbers are rational)
Line 34: Line 34:
field of arithmetic in the particular language"? With the use example
field of arithmetic in the particular language"? With the use example
being Rational Arithmetic. [[User:NevilleDNZ|NevilleDNZ]] 13:08, 14 February 2009 (UTC)
being Rational Arithmetic. [[User:NevilleDNZ|NevilleDNZ]] 13:08, 14 February 2009 (UTC)

: I see what you are saying, but, Python isn't Ipython - we should explicitly explain when functionality is added by libraries that are not part of the standard distribution. --[[User:Paddy3118|Paddy3118]] 16:26, 14 February 2009 (UTC)

Revision as of 16:26, 14 February 2009

Too long

Gosh, this task seems far too long. I would suggest the task change to be something like the definition of a rational together with the demonstration of its use in computing the addition and subtraction of two rational numbers.

Leave out the class based, and operator overloading to include more languages; and cut down on the definition of operators.

Another, separate task could focus on operator overloading. --Paddy3118 12:58, 13 February 2009 (UTC)

Agreed. This task should simply be about the definition of a rational type and maybe a couple of helper functions (like reduction). There should be no operator definition in this task. That is covered elsewhere. If you still want the operator functionality, then named functions would be preferred so the task isn't restricted to languages with operator definition. --Mwn3d 13:47, 13 February 2009 (UTC)
Actually, if you want the operator functionality, you should simply say "provide a means to do blah," so that languages can use their idiomatic approach, be it operator overloading, function calls, etc. --Short Circuit 16:06, 13 February 2009 (UTC)

I just changed the task definition, and pruned the code and examples back to the minimum required. I suspect that the original code in Python would be really short as python can leverage off duck typing. However ALGOL 68 requires the programmer to MANUALLY define ALL associated assignment operators (e.g. +:=, -:= etc) together with ALL the UPPERCASE equivalent operator, e.g. PLUSAB, MINUSAB etc (to provide portability to wrist watches and main frames). The net effect is an explosion of operator definitions. NevilleDNZ 21:53, 13 February 2009 (UTC)

languages that already implement rational numbers?

What about for languages that already implement rational numbers? Should we re-implement them? --Spoon! 05:00, 14 February 2009 (UTC)

how about them just noting that fact and maybe giving an example of their use? --Paddy3118 07:04, 14 February 2009 (UTC)
Huh, technically, numbers in all computer languages I know are rational. Integer, fixed- and floating-point numbers of any natural radix are rational. Well, ideals NaN and +/-Inf of IEEE 754 aren't rational, though this does not count, because the rest is rational. I remotely remember some implementations of numbers based on Pi or e radix. Those are not rational. Complex numbers are not rational, of course. IMO the task name is quite misleading. It is looks more like a certain representation of rational numbers to be used in order to implement a certain subset of Q. --Dmitry-kazakov 14:10, 14 February 2009 (UTC)

IMHO It certainly should be noted if a language already has Rational Arithmetic. For example IPython (in the form of Sage) certainly has Rational Numbers.

Sage even has these operators for arithmetic on algebraic expressions, modulo arithmetic, and differential forms and more.

Maybe we could make the task as "demonstrate how to implement a new field of arithmetic in the particular language"? With the use example being Rational Arithmetic. NevilleDNZ 13:08, 14 February 2009 (UTC)

I see what you are saying, but, Python isn't Ipython - we should explicitly explain when functionality is added by libraries that are not part of the standard distribution. --Paddy3118 16:26, 14 February 2009 (UTC)