public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "warp at iki dot fi" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/42184]  New: Same literal behaves differently as a double than as a long double
Date: Thu, 26 Nov 2009 16:06:00 -0000	[thread overview]
Message-ID: <bug-42184-1764@http.gcc.gnu.org/bugzilla/> (raw)

One would assume that the following program prints the same number four times,
but instead "1 0 1 0" is printed. I compiled it with options "-std=c99 -lm".

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

int main(void)
{
    long double value1 = 1.6646342e21;
    long double value2 = 1.6646342e21L;
    long double value3 = strtod("1.6646342e21", NULL);
    long double value4 = strtold("1.6646342e21", NULL);
    long double divisor = 1.25L;

    printf("%Lg %Lg %Lg %Lg\n",
           fmodl(value1, divisor), fmodl(value2, divisor),
           fmodl(value3, divisor), fmodl(value4, divisor));

    return 1;
}


-- 
           Summary: Same literal behaves differently as a double than as a
                    long double
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: warp at iki dot fi
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42184


             reply	other threads:[~2009-11-26 16:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-26 16:06 warp at iki dot fi [this message]
2009-11-26 17:13 ` [Bug c/42184] " kargl at gcc dot gnu dot org
2009-11-26 21:12 ` pinskia at gcc dot gnu dot org
2009-11-26 21:15 ` pinskia at gcc dot gnu dot org

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=bug-42184-1764@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).