Ad
  • Custom User Avatar

    Needs lots of other decimals with varying number of significant digits.

    And 1 random test cases is far from enough. Not to mention that you pass -2 as the second parameter, basically nullifying whatever random tests are supposed to do.

  • Custom User Avatar

    The function does not need to deal with very big numbers, or any invalid input which was not mentioned.

    Except you have string inputs. Strings are not numbers.

    Also, roundAndPad(-1.1232,19) == "-1.1232000000000000000" does not make much sense because double precision floats doesn't have 19 digits of precision anyway, so if you're rounding it to 19 decimal places you'll get stuff like -1.1231999999999999762.

  • Default User Avatar

    If d is negative, then the function just returns n.

    Taking types into consideration, this is not true. The test suite still expects a string when d is negative, rather than the number n itself.