From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26937 invoked by alias); 4 Feb 2019 14:39:59 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 26216 invoked by uid 89); 4 Feb 2019 14:39:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=nearest, HX-HELO:sk:mail-ed, myers, sk:joseph X-HELO: mail-ed1-f43.google.com Received: from mail-ed1-f43.google.com (HELO mail-ed1-f43.google.com) (209.85.208.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Feb 2019 14:39:57 +0000 Received: by mail-ed1-f43.google.com with SMTP id x30so83915edx.2 for ; Mon, 04 Feb 2019 06:39:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=ukeoGwfL8dTgks/vPZcylCuO7pVc5VV5ETyau2HtbQU=; b=frYypfvEHPuOIxrKrlKLoHAiZ+6McEnRJ5W8tVIAyUs+PtUwGD8iGVFLyRLL9WBcZ6 aUho7ioc+rYTOdaFomjlI4rMzN/D8iWZYBemu0tmXqeMq+qTEr1sT0v4Z517Qg6rndai GkcHCMyoi1BlvJpiMGxzd5j921SXHe9sgHnZb0ac3vZrdjEqQ65k2e2n6S0j4rxmyCer /fu4V+wKwJnCgABRit0RrBi4c4ITRrK2fpTgEutBht8I01RFC0zxdV/OPR2uFU13XJH6 NkisZGGCHlX1wIR5z4g+uIcmRpAoiI41WAehD2v64oR3RAHZL697x2fWH/hjw69sBKsV h2VQ== MIME-Version: 1.0 References: In-Reply-To: From: Tejas Joshi Date: Mon, 04 Feb 2019 14:39:00 -0000 Message-ID: Subject: Re: About GSOC. To: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-02/txt/msg00007.txt.bz2 Hello. I have implemented roundeven function in real.c as follows: (and respective changes in real.h) /* Round X to nearest even integer towards zero. */ void real_roundeven (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x) { REAL_VALUE_TYPE t; do_fix_trunc (&t, x); HOST_WIDE_INT i = real_to_integer (&t); if(i % 2) do_add (r, &t, &dconstm1, 0); else *r = t; } Although I cant get it to test like int foo() { double x = __builtin_roundeven (3.5); printf("%f",x); return (int) x; } Because I do not know its dependencies through other files. I tried to track them down by inspecting real_ceil function, but it also includes other optimization procedures like folding. How do I know enough declarations to be made in respective files? Thanks. -Tejas On Mon, 28 Jan 2019 at 22:33, Tejas Joshi wrote: > > Hello. > Representations of real numbers in real.c are a little complex to > understand right now for me. I am still trying to understand them and > figure them out using gdb and cscope. Though conventions are given in > comments in real.c, I will still be trying to figure it out. The > equation and its bitwise representation is not pretty elaborated in > any documentation I could find. > > x = s * b^e * \sum_{k=1}^p f_k * b^{-k} > > where > s = sign (+- 1) > b = base or radix, here always 2 > e = exponent > p = precision (the number of base-b digits in the significand) > f_k = the digits of the significand. > > In mean time, I've tried real_round function to work like roundeven. I > will try to submit a clean patch along with roundeven implemented > separately with changes like in builtins.def, adding cases, etc. > > void > real_round (REAL_VALUE_TYPE *r, format_helper fmt, > const REAL_VALUE_TYPE *x) > { > #if 0 > do_add (r, x, &dconsthalf, x->sign); > do_fix_trunc (r, r); > if (fmt) > real_convert (r, fmt, r); > #endif > fprintf (stderr, "\nhere\n"); > real_value z; > do_fix_trunc (&z, x); > HOST_WIDE_INT i = real_to_integer (&z); > fprintf (stderr, "\n i = %ld\n", i); > if (i % 2) > do_add (r, &z, &dconstm1, 0); > else > *r = z; > } > > Thanks. > -Tejas > > On Sat, 26 Jan 2019 at 03:02, Joseph Myers wrote: > > > > On Sat, 26 Jan 2019, Tejas Joshi wrote: > > > > > function with byte-byte comparison which also include mpfr. (Correct > > > me if I am wrong.) What is the significance of mpfr related to these > > > internal representations? > > > > real.c provides a fixed-size representation of floating-point numbers that > > allows for various non-IEEE formats supported by GCC, and also allows > > functions from dfp.c to be used for decimal floating-point formats. > > > > MPFR is used in GCC to provide operations that are nontrivial to > > implement, especially those that are nontrivial to implement in such a > > fixed-size context. real.c operations wrap around MPFR ones where > > appropriate, doing whatever's needed in cases where there are non-IEEE > > semantics or sets of values. > > > > -- > > Joseph S. Myers > > joseph@codesourcery.com