Ad
  • Custom User Avatar

    tht s nothing. i just fixed it . But my code did pass all the tests anyway

  • Custom User Avatar

    Tests are not ideal but they are correct. It is hard to create randomized tests which catch all possible bugs. Your solution does not work for some simple test cases like this one:

    ( -9.21+ -8.97* -0.00+6.51+(5.50+6.81))
    

    The expected result is 7.263867809057526 but your solution returns -915.278670000000034.

    A simplified version of this test case:

    ( -9+ 8*0+6+(5+6))
    

    Expected: 8, your solution: 799.087999999999965.

  • Custom User Avatar

    Dude u gotta improve the tests, 'cuz i tell ya, they’re broken! Sometimes my code passed sometimes it didn’t.also there were two cases in the fixed tests where my code gave me the right answer when tested in VSCODE, but your tests gave me a totally different answer. Note that I used the same code! To solve this issue, i had to manually handle these two cases! You gotta revise your tests guys, they’re broken!

  • Custom User Avatar

    Yes, it is always true for Java and for any sane programming language. You still need to be careful with more complicated expressions and if you use a low-level programming language like C with specific compiler flags (e.g., --ffast-math): It is possible that you get different results on different machines even if they are IEEE-754 compliant.

    Historically, the original version of Java was not strict with floating-point arithmetic and it was possible to get different results on different machines (but always the same results on the same machine). That's why Java had the modifier strictfp to make sure that floating-point results are reproducible (it was removed in Java 17).

  • Custom User Avatar

    Sorry for a bit dumb question.

    Does this mean that if I do something like

    float a = 1.0f / 3.0f;
    float b = 1.0f / 3.0f;
    System.out.println(a == b);
    

    on one machine it's always going to be true?

  • Custom User Avatar
  • Custom User Avatar

    You guys shouldnt be allowed to make any KATA. My experience was horrible. tht s the first time i had an experiance tht bad on codewars. The creators of this KATA are so terrible! Anyway i solved it but i am not satisfied!

  • Custom User Avatar

    Please do not open new issues unless you can confirm that your solution is correct and tests are wrong. Floating-point arithmetic is not random. You always get the same result if you follow all computation steps in the specified order. Did you see my reply to your previous issue?

  • Custom User Avatar

    calculate (((7.20/ -3.84- -2.23-9.14/7.037.42+ -8.85+8.12-8.73+7.39/(7.15+6.73+8.91/8.36+8.16/9.75)))+((7.46)-7.07-7.26/7.33/6.91+5.45-9.308.22/9.55-9.99*(6.71/ -6.70-5.05/ -7.75+9.839.47+8.04+6.90)/7.40+7.828.84+8.14+9.95+(6.35))/(((8.58+5.40+ -7.258.20/8.568.03+8.02-9.09/ -1.137.93/6.06+ -9.21+9.93+6.01+9.896.38/9.39* -1.17/ -9.58- -8.42/8.42+ -1.36/6.33/ -6.85+5.42+9.32+7.82+9.41+7.75+8.03/ -7.52)))) should be -20.5390898263107289, got -20.5390898263107253 can someone solve this ,everyone knows floating point has limitations u guys cant ask for this level of precision in your tests when it comes to float ! Been working on this problem for almost 12 hours , 3 hours per day and now cant ask me to come up something tht s impossible

  • Custom User Avatar

    Both Python and JavaScript return -20.490663944447256 for this expression. So there are no issues with tests.

    Make sure that you evaluate all operations with the same precedence from left to right and use library functions to convert decimal numbers to floating-point numbers.

    Your current solution fails the following simple test case: 1-(6-3) == -2 but you solution returns 1.

  • Custom User Avatar

    "calculate ( -7.42/7.83-5.98* -5.01/9.08* -8.59+8.80) should be -20.490663944447256, got -20.4906639444472596" Why am i getting this is it my code or an issue with the tests?

  • Custom User Avatar

    I am backk! Lts go bby!!!

  • Custom User Avatar
  • Custom User Avatar

    So this kata penalizes you for writing good code by falsely interpreting as an imported module? Huh?

  • Custom User Avatar

    "You have passed all of the tests! :) " I passed the soft tests btw xD!

  • Loading more items...