Skip to main content

Timeline for Expand the number

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Nov 4, 2016 at 15:28 comment added metalim @user81655 Comment "the input will conform to" refers to invalid inputs - there are no 006 or 0.100 inputs allowed. Program should work for all valid inputs. As for floating point number representation: text representation is strict and easy: 0.3 does not equal 0.300000whatever. Task of a developer is to make a program that conforms to the requirements, not to explain the quirks of implementation instead.
Oct 30, 2016 at 23:18 comment added user81655 @metalim In regards to your first tests, floating-point numbers cannot represent every real number. That's just how they work. The question asks for a floating-point number, so I'd assume your first examples are allowed. For the others, as I state in the description: "Requires the number to be input as a string without leading zeroes". This is explicitly allowed by the question with "You need neither spaces between the +'s nor the zero before the decimal point" and the OP's comment "the input will conform to the same restrictions as the output".
Oct 28, 2016 at 7:26 comment added metalim Test doesn't work for following: .3 -> 0.30000000000000004, .6 -> 0.6000000000000001, .7 -> 0.7000000000000001, and more importantly: 0.1 -> 0.01, 0.01 -> 0.0001, etc. All zeroes get doubled. So pretty much solution is broken. Solution is not about "someone's fault", but about "it works". DNQ.
Jan 20, 2016 at 20:50 comment added Neil @DomHastings Still wouldn't work for n=0.1 anyway.
Jan 19, 2016 at 22:32 comment added user81655 @DomHastings Almost. It fails for n<1 because the 0| will make p equal 0 for both 0.1 and -0.1. The shortest way I can think of is p=Math.log10(n),p=p-(p<0)|0 which is the same length as using Math.floor. :(
Jan 19, 2016 at 9:57 comment added Dom Hastings Can you use 0|Math.log10(n),p-=p<0 instead of Math.floor(Math.log10(n))?
Jan 18, 2016 at 22:03 history edited user81655 CC BY-SA 3.0
Fixed bug
Jan 10, 2016 at 23:22 comment added user81655 @ETHproductions If the input number is less than 1 it would break because Math.log10(n) would return a negative number and |0 rounds towards zero instead of flooring.
Jan 10, 2016 at 22:54 comment added ETHproductions Math.floor => 0|...?
Jan 9, 2016 at 4:14 history answered user81655 CC BY-SA 3.0