Ad
  • Custom User Avatar

    It is stated that 1--1 is valid and that an unary minus is not separated by a whitespace before parentheses. Your example follow these rules.

  • Default User Avatar

    Hi everyone, I use haskell language.

    In random tests, I get a random input string
    "((((94.0))-54.98))-89.28-(88.66)+-59.25+75.61+4.88/(44.42)/(79.75)*-60.81*3.72/(19.72*10.46)-58.1/(7.55)*23.37+32.0/(97.63)-(79.92*(1.71-16.82))/(--(28.95)/((55.88/(67.58))))/(69.66)+95.05*(37.3*(5.1*44.66*39.81)-17.23)*80.85+(48.43/(86.06))*(-88.39)/((32.31-31.49*32.76))"
    to calc, I get a substring --(28.95), Is that right? I am not found this rule in the description.

  • 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
  • Loading more items...