Talk:Getting the number of decimal places: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 15: Line 15:
:: Infinity ? (we read <code>pi</code> as bound to a mathematically defined value) ?
:: Infinity ? (we read <code>pi</code> as bound to a mathematically defined value) ?
:: Something else ? (we read <code>pi</code> as a system constant, bound to some unspecified member of a zoo of types that might include creatures like i32, i64, i128, or perhaps even their cousins u32, u64, u128, each of which would contain expansions of pi to different digit lengths) ? [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 09:10, 14 August 2020 (UTC)
:: Something else ? (we read <code>pi</code> as a system constant, bound to some unspecified member of a zoo of types that might include creatures like i32, i64, i128, or perhaps even their cousins u32, u64, u128, each of which would contain expansions of pi to different digit lengths) ? [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 09:10, 14 August 2020 (UTC)

:: To concretise a little, the initial Python suggestion just errors when the given number is math.e, math.pi, or math.tau [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 09:22, 14 August 2020 (UTC)

Revision as of 09:22, 14 August 2020

Fractions? Trailing Zeros?

What exactly is meant by 'number' in the task description? Fractions are numbers. 1/4 is a fraction whose decimal expansion contains two decimal places. 1/3 is a fraction whose decimal expansion contains an infinite number of decimal places. Are we not meant to handle fractions, even if our language features them as first-class literals?

Can we also get some clarity regarding trailing zeros? Most languages feature numeric types that do not retain trailing zeros. I see that some entries are using strings for these cases instead. Is that intended by the task?

Floating point numbers may also be problematic as mentioned in the Raku entry. By the way, how many decimal places does fp-zero have? How about fp-infinity?

Should we also handle other numeric types with decimal points? Many languages feature some sort of 'BigDecimal' type and complex number type, for example.

It would be nice if the task description could elaborate on some of the above concerns. A restriction of the scope of the task (beyond merely 'numbers'), as well as having an actual task to solve beyond a couple cryptic inputs and outputs would be much appreciated as well. --Chunes (talk) 12:22, 13 August 2020 (UTC)

The description doesn't even exert itself unduly on the question of whether the input value is a String or something else :-)
What is the expected result when the input is pi ?
0 ? (we read pi as a string ?)
Infinity ? (we read pi as bound to a mathematically defined value) ?
Something else ? (we read pi as a system constant, bound to some unspecified member of a zoo of types that might include creatures like i32, i64, i128, or perhaps even their cousins u32, u64, u128, each of which would contain expansions of pi to different digit lengths) ? Hout (talk) 09:10, 14 August 2020 (UTC)
To concretise a little, the initial Python suggestion just errors when the given number is math.e, math.pi, or math.tau Hout (talk) 09:22, 14 August 2020 (UTC)