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

 
(20 intermediate revisions by 8 users not shown)
Line 9:
 
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. --[[User:Chunes|Chunes]] ([[User talk: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 <code>pi</code> ?
:: 0 ? (we read <code>pi</code> as a string ?)
:: 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 f32, f64, i32, i64, i128, or perhaps even their cousins u32, u64, u128, each of which would contain expansions of pi to different digit lengths - most of them zero) ? [[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, all of which have Python type `float` and are quite hard not to think of as 'numbers', in terms of the task title. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 09:22, 14 August 2020 (UTC)
 
===Strings===
 
The "number of decimals" I took as being a function of how a number is represented. It is either stated implicitly or implied by its ''string'' representation. 1.0, 1.00, 1.000, and 1.0000 would all have the same floating point value in Python, but when read can suggest differing levels of precision used in calculating a value, (at least in Physics and Engineering when they pay attention to significant digits). --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 08:12, 16 August 2020 (UTC)
: Normally I would agree, but the reference implementation (Ring) does no string parsing whatsoever as far as I can tell. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 08:45, 16 August 2020 (UTC)
:: And if this were really intended as a function over a string (the reference implementation and task description both indicate otherwise), it would be far too trivial to be worth promoting to task status. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 08:54, 16 August 2020 (UTC)
 
Just trying to bring some meaning to an obscure ''description''. What other way is there to distinguish 12.3450 of the description from 12.345 or 12.34500 in Python (and a lot of other languages)? --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:31, 16 August 2020 (UTC)
: It's very curious that the Ring entry doesn't bother to show the examples from the task description. Does it even work? --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 09:41, 16 August 2020 (UTC)
 
:: I've [http://rosettacode.org/wiki/User_talk:CalmoSoft#Getting_the_number_of_decimals invited] the original author to join in the discusions... --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:48, 16 August 2020 (UTC)
 
Hmm, still no input from the original author. The task description together with its initial implementation from the originating author are imprecise. This needs changing or abandoning. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 15:42, 23 August 2020 (UTC)
 
: I think it's too early to throw the baby out with the bath water. &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 23:57, 23 August 2020 (UTC)
 
 
== wording of the task ==
 
I had a little uneasiness when reading &nbsp; ''get the number of decimals''. &nbsp; &nbsp; &nbsp; I presumed several things. &nbsp; &nbsp; &nbsp; --- Yeah, yeah, &nbsp; I know what presumption can do and what it can lead to --- a very steep and fast decent into chaos and self-fulfilling definitions. &nbsp; But, I trudged on.
 
By &nbsp; ''decimals'', &nbsp; I presumed the task's author meant decimal ''digits'', &nbsp; that would presume &nbsp; (to me) &nbsp; that the number is expressed in base ten, &nbsp; or is to be converted to base ten, &nbsp; depending on what programmers are assuming whatever flavor of expressing numbers that their (favorite) computer programming language(s) assumes/uses such animals.
 
By all the other programming examples, &nbsp; included the task's preamble, &nbsp; I also understood &nbsp; (and observed) &nbsp; that the &nbsp; ''number&nbsp;of&nbsp;decimals'' &nbsp; implied that it meant the &nbsp; ''number&nbsp;of&nbsp;decimals'' &nbsp; (decimal&nbsp;digits) &nbsp; &nbsp; <u>past the decimal point</u> &nbsp; &nbsp; &nbsp; (if there is a decimal point).
 
If there's no decimal point, &nbsp; then define/assume that the number of decimals &nbsp; (past the decimal point) &nbsp; is zero.
 
Another &nbsp; (perhaps more descriptive) &nbsp; use of the phrase &nbsp; '' decimal&nbsp;digits'' &nbsp; (past the decimal point) &nbsp; would be &nbsp; ''fractional&nbsp;digits''.
 
I further assumed that &nbsp; if &nbsp; a number was expressed in exponential format, &nbsp; the number should/would be converted to a number without exponentiation, &nbsp; and then &nbsp;that&nbsp; number would be then examined.
 
I took the word &nbsp; '''get''' &nbsp; to mean &nbsp; ''obtain'', &nbsp; ''find'', &nbsp; or &nbsp; ''determine'', &nbsp; and then, presumably, &nbsp; display/show the results. &nbsp; &nbsp; (With the usual caveat: &nbsp; ''here, on this page''.)
 
After all, if one &nbsp; ''gets'' &nbsp; (obtains) &nbsp; the number of decimals in a given number, &nbsp; then what? &nbsp; Display them? &nbsp; Everybody &nbsp; (so far) &nbsp; has seemed to just display the &nbsp; ''number'' &nbsp; of decimal (digits) found &nbsp; that are past the decimal point.
 
I understand that number of computer programming language's internal representations of decimal numbers with fractional digits don't have a concept of superfluous decimal zeros, &nbsp; unless the decimal number is, for instance, enclosed in quotes and/or by some other notation(s). &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 23:57, 23 August 2020 (UTC)
 
: Hi Gerard, The task, as you demonstrate, is not specific enough. Maybe there is some standard we could re-write the task to more closely adhere to, as others have interpretations that work for them, but are different. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:42, 24 August 2020 (UTC)
 
== C/C++ marked incorrect ==
I assume it would be fair to say that the output of findNumOfDec() is correct, it is just that the display of x in test() is lacking? --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 13:02, 20 March 2023 (UTC)
 
: The task description gives 2 examples, one of which is " for num = 12.3450 decimals = 4" so for 12.0 and 12.345000 how many decimals do you think should be reported? How does this compare with the C output?--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 15:40, 20 March 2023 (UTC)
 
:: Oh yes indeed, by that definition I'd have to say the FreeBASIC, Haskell, Java, Kotlin, Ring, RPL (probably), Sidef entries are all equally "wrong". Personally I want to say that 12.3450 should have 3 decimal places, even though my own entry shows 4 for "12.3450", but in reality 12.345 is held as ~12.3450000000000006 in a 64-bit IEE754 float, and as ~12.34500000000000000024 in an 80-bit float, so that would be 16 and 20 decimals, at least in some "sense". Stupid task. Anyway, you (by which I mean Peak) either have to be consistent and badger everyone, or no-one, or better yet fix the stupid task description (after discussing it here first). --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 16:08, 20 March 2023 (UTC)
 
:::Well, stupid or not, the task is what it is. As the original author hasn't been around lately, I've fixed the C/C++ entries using strings rather than doubles as there's no way those languages can distinguish between 12.345 and 12.3450 otherwise. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 17:56, 20 March 2023 (UTC)
 
:::: Good-oh. My main concern was that C/C++ were being unfairly picked on and "incorrect" was just as imprecise as the tesk description. --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 06:55, 21 March 2023 (UTC)
7,795

edits