Talk:Convert decimal number to rational: Difference between revisions

Content added Content deleted
(→‎Repetitive digit chains and rounding: Second param for count of repeating digits)
(→‎Decimal?: Yes, decimal (rational))
Line 10: Line 10:
:Well if you can express it as a finite decimal expansion ... :-)<br>--[[User:Paddy3118|Paddy3118]] 11:44, 12 June 2011 (UTC)
:Well if you can express it as a finite decimal expansion ... :-)<br>--[[User:Paddy3118|Paddy3118]] 11:44, 12 June 2011 (UTC)
:Presumably we are only working to the precision (or double precision) of the system registers, (or to the number of digits originally provided in numerical string based implementations), so the values would all be rational. --[[User:Markhobley|Markhobley]] 12:28, 12 June 2011 (UTC)
:Presumably we are only working to the precision (or double precision) of the system registers, (or to the number of digits originally provided in numerical string based implementations), so the values would all be rational. --[[User:Markhobley|Markhobley]] 12:28, 12 June 2011 (UTC)

:Definitions: Rationals - the real numbers constructible as ratio of A/B, where A and B are both integers. Irrationals - the real numbers that cannot be expressed as such a ratio.
:The set of rationals exactly matches the set of numbers with decimal expansions that either terminate (i.e. fixed length), or become periodic (i.e. written it with a bar over the last N digits).
:The set of irrationals exactly matches the set of numbers with decimal expansions that neither terminate nor become periodic.
:Therefore, there is no way to put an irrational number into your code as a decimal number, even if you can also indicate number of repeating digits. You *can* say PI or sqrt(2) in most languages, but what you get from those is just the largest (truncated) decimal version that fits into your floating point representation.
:To summarize, IMHO, *yes*, only rationals make sense for this task. --[[User:Util|Util]] 14:49, 12 June 2011 (UTC)


== Repetitive digit chains and rounding ==
== Repetitive digit chains and rounding ==