2

For example, I want to ask if something is correct, like this question:

Floating-point number multiplication: a * 1.0 == a guaranteed?

What I actually want to ask:

For float point numbers a,b and c, if a/b exactly equals to c in decimal, and a, b, c are all representable with float numbers without rounding errors, eg:7/2==3.5, would there be any case that cause a/b not equal to c in float point calculations (eg:7/2 becomes 3.49999999 incorrectly...)?

what should I fill in the "What did you try"?

6
  • 13
    Nothing. You don't have to say what you tried.
    – Dharman Mod
    Commented Jun 14, 2023 at 9:36
  • 1
    @Dharman While that agrees with policy for what questions should look like, currently new users are (to my understanding) subjected to the Ask Wizard, which has a separate box prompting for that information with a 20 character minimum (which it will then blindly concatenate with the actual question entry box). Commented Jun 14, 2023 at 12:31
  • 1
    "if a/b exactly equals to c in decimal, and a, b, c are all representable with float numbers without rounding errors" - there are quite few cases that this actually describes. Commented Jun 14, 2023 at 12:32
  • @karl Are you sure it's mandatory? That seems like a terrible design.
    – Dharman Mod
    Commented Jun 14, 2023 at 12:33
  • 1
    Well, what did you try? Did you try running a program that iterated over a large quantity of numbers and validate the result is not rounded incorrectly? Do you need help producing such a program? That would be a question I would ask... Commented Jun 15, 2023 at 20:54
  • @Dharman see "Why are first-time askers not allowed to opt out of the Ask Wizard?" in The Ask Wizard (2022) has graduated.
    – Ryan M Mod
    Commented Jun 20, 2023 at 4:43

1 Answer 1

3

What you tried for general cases could include tests for specific cases that hold for the inquired general case. Using Floating-point number multiplication: a * 1.0 == a guaranteed? as an example, what one might try while attempting to answer the question themselves could be attempting to multiply many different numbers of many different magnitudes with 1.0 and testing if they are the same, and doing so on specific implementation(s). Doing so will either:

  • Result in a case where the general case/guarantee fails, thus answering the question. (i.e. No)
  • All attempted tests appear to follow a general case, thus warranting asking the question to get an answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .