Author Topic: Problem with immediate math: caused by C::B or MinGW?  (Read 3040 times)

gmontag451

  • Guest
Problem with immediate math: caused by C::B or MinGW?
« on: May 01, 2018, 10:35:08 pm »
I'm having an issue where a math equation which is entered in immediate mode does not resolve properly. Because the equation is entered in immediate mode, it's processed before compiling. I understand that C::B is an IDE, but I'm uncertain if this preprocessing is handled by Code::Blocks or by MinGW?

(The problem is 5 * 2 / 6 * 6 / 2.  It evaluates to 3, when to my knowledge, the answer should be 5. I'm using C::B with MinGW for C programming.)

Michael
« Last Edit: May 01, 2018, 10:41:44 pm by gmontag451 »

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 203
Re: Problem with immediate math: C::B or MinGW?
« Reply #1 on: May 01, 2018, 10:42:17 pm »
It's not a c::b nor a mingw issue:

5*2/6*6/2=(((5*2)/6)*6)/2=((10/6)*6)/2=(1*6)/2=6/2=3.

Thread sould be closed.

gmontag451

  • Guest
Re: Problem with immediate math: caused by C::B or MinGW?
« Reply #2 on: May 01, 2018, 10:58:31 pm »
As per every single calculator I own, as per Google, as per PEMDAS etc. etc. the answer ought to be 5.

At least your answer revealed that you and the computer round 10/6=1.6667 to 10/6=1, which certainly isn't kosher. Perhaps you might have been better to have explained WHY that's ok in your eyes.

"Thread sould be closed." A bit unecessarily trite, don't you think? Asking for help is what forums are for. If I'm in the wrong place, you could say so. But your dismissive response is inappropriate by anyone's measure. Absolutely no excuse for abusing newcomers.

« Last Edit: May 02, 2018, 12:07:17 am by gmontag451 »

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 203
Re: Problem with immediate math: caused by C::B or MinGW?
« Reply #3 on: May 02, 2018, 12:07:31 am »
This forum is related to Code::Blocks:
http://forums.codeblocks.org/index.php/topic,9996.0.html

Your problem is not related to c::b but "integer division".

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Problem with immediate math: caused by C::B or MinGW?
« Reply #4 on: May 02, 2018, 12:38:02 am »
As per every single calculator I own, as per Google, as per PEMDAS etc. etc. the answer ought to be 5.

At least your answer revealed that you and the computer round 10/6=1.6667 to 10/6=1, which certainly isn't kosher. Perhaps you might have been better to have explained WHY that's ok in your eyes.

"Thread sould be closed." A bit unecessarily trite, don't you think? Asking for help is what forums are for. If I'm in the wrong place, you could say so. But your dismissive response is inappropriate by anyone's measure. Absolutely no excuse for abusing newcomers.
Your absolutely wrong.

Please read theforum rules, as you obviously did not before posting.
Especially:
This post is here to assist you in your Code::Blocks / C++ blues, by telling you what NOT to do. This is not to frighten you, but unfortunately we have to be that strict due to continuous mis-use and dis-respect.

1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework", "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.

2. Compiler/Linker errors are NOT Code::Blocks errors. Usually, C++ newcomers tend to confuse the Editor/IDE (Code::Blocks) with the Compiler (MINGW / GCC). You may see some errors in the compiler output because you missed to do something right in your code. But that's not Code::Blocks troubleshooting, that's C++ troubleshooting and does not belong in here. If your program doesn't compile, READ THE C++ MANUAL.

...

7. Only after you have checked everything out and you're sure it's a Code::Blocks configuration problem / bug and not a C++ problem, post it.

...

Finale note: Ignoring these rules may result in the topic being (silently) locked and/or even removed completely without any notice.

In case you wonder why we are so strict: I could say: "Search the forum" - as this has been discussed a lot. To make is short: By law we (the devs/moderators) are responsible for the content of our forum. This means we need to read all posts. If you want us to continue the development of C::B and have the time to answer some of the questions that are really related to C::B, apply the rules above. It's obviously a matter of time for us.

More general help how to use our forum you'll find here, too.

Thread closed because it violates these rules.