Ad
  • Default User Avatar

    the C++ test case (w = 86.7, h = 1.7) was problematic because the orer of operations affected the result. removed.

  • Default User Avatar

    In Rust, there is a distinction between to_ascii_lowercase and to_lowercase.
    to_ascii_lowercase is specifically designed for ASCII characters, while to_lowercase is used for Unicode characters.
    to_lowercase function should be used for general case conversion of characters, including non-ASCII characters.
    This is due to the fact that Rust doesn't simplify for you the strings.
    "hello world" has obviously 11 characters, but it is not always 8 bit each, hence, the necessity for different methods based on the type.
    I'm studying rust, and maybe my explanation it is not 100% correct. The free microsoft course for Rust explains very well strings, but the rust doc go deep inside the problem: https://doc.rust-lang.org/std/primitive.char.html

  • Custom User Avatar

    But there's no harm in doing that.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    I've asked my friends, who did same things. I think that just lack of understanding, like "I return 'num' but result of equation is hung in the air... Somewhere".

  • Default User Avatar

    just seeing it now i thought const int will not be able to store in an int

  • Custom User Avatar

    Just in case a geomagnetic storm happens, and these variables suddenly turn into something else.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Yes, if returning a static label. It points to program data segment.

  • Custom User Avatar

    Why?

    (side-note to your answer: are there cases where it cannot be avoided?)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    In memory when you store double it's more of an approximation and ONLY accurate to a certain amount of bits like 15 I think? So when you try to use 1.7 * 1.7 its more like 1.6999...55 * 1.69999......5555. As you multiplty things with uncertainty the rate of uncertainty compounds so you're moving up the errors higher and higher to a point where it gets recognzied by the compiler as an actual value.

    Atleast I think that's what it is. You can see this if you initialize a double var to a value in something like VS code, when you hover over the var it'll show you a number thats slightly off.

  • Custom User Avatar

    In this exact case std::begin() will just call vector.begin(), so no difference really, only that std::begin() is more generic function.