public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: frijolithedog 1 <frijolithedog@outlook.com>
To: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: C programing problem where <= is interpreted as < when using GCC 11.2.0
Date: Thu, 14 Oct 2021 15:20:42 +0000	[thread overview]
Message-ID: <PSAPR04MB4311D65521A8CD3B0E2820EBB4B89@PSAPR04MB4311.apcprd04.prod.outlook.com> (raw)

I am having a C programing problem where <= is interpreted as < when using GCC 11.2.0

I was debugging a larger program which I broke down into smaller sections of code and I noticed
the following code was not working correctly:

#include <stdio.h>
#include <math.h>
#include <float.h>​

int main(void)
 {
       float n, step;

       step = 0.1;

           for (n = 2; n <= 10; n = n + step )
           printf("%3.4f\n", n );                     /*  This stops at 9.9000 and not at 10.0000  */

 }

I tried the above code only using the following include statement
#include <stdio.h>
but the result was the same.

And I also wrote the following code to try and do the same thing in a different way and
the output was the same as the above code:

#include <stdio.h>
#include <math.h>
#include <float.h>

int main(void)
 {
       float n, step;

       n = 2.0;
       step = 0.1;

           do
          {
             printf("%3.4f\n", n);       /*  This stops at 9.9000 and not at 10.0000   */
             n  = n + step;

           } while  (n <= 10);
 }

I am new to programing and the following details may help you:

I followed the instructions at this site:
https://winlibs.com/
WinLibs standalone build of GCC and MinGW-w64 for Windows

and I downloaded the following:

Release versions
UCRT runtime

    GCC 11.2.0 + LLVM/Clang/LLD/LLDB 13.0.0 + MinGW-w64 9.0.0 - UCRT - release 2   (LATEST)
        Win32: 7-Zip archive* | Zip archive   -   without LLVM/Clang/LLD/LLDB: 7-Zip archive* | Zip archive
        Win64: 7-Zip archive* | Zip archive   -   without LLVM/Clang/LLD/LLDB: 7-Zip archive* | Zip archive

I clicked on the Zip archive highlighted in yellow which does not include LLVM/Clang/LLD/LLDB

I then went to this site
https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-13.0.0-9.0.0-ucrt-r2/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64ucrt-9.0.0-r2.zip
and downloaded
winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64ucrt-9.0.0-r2.zip

The Operating System I am using is Windows 7.

I have been to your site https://gcc.gnu.org/pipermail/gcc-help/
and searched your Archives back to July viewing by Thread and by Subject
and the search term I used was the less than or equal to symbol  <=
but if the answer was there I am sorry but I missed it.

I have also searched the GCC Manual for version gcc-11.2.0
but if the answer was there I am sorry but I missed it.

Thank you for any assistance you can give me.

Bob

             reply	other threads:[~2021-10-14 15:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 15:20 frijolithedog 1 [this message]
2021-10-14 15:31 ` Xi Ruoyao
2021-10-14 17:14 ` Jonathan Wakely
2021-10-23 13:43 frijolithedog 1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PSAPR04MB4311D65521A8CD3B0E2820EBB4B89@PSAPR04MB4311.apcprd04.prod.outlook.com \
    --to=frijolithedog@outlook.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).