Re: gcc strangeness

From: Roman Kurakin (rik_at_cronyx.ru)
Date: 07/12/04

  • Next message: Scott Long: "[REMINDER] Call for FreeBSD status reports"
    Date: Mon, 12 Jul 2004 11:50:04 +0400
    To: Dmitry Morozovsky <marck@rinet.ru>
    
    

    Dmitry Morozovsky wrote:

    >Dear colleagues,
    >
    >one of my friends has raisen very strange issue regarding gcc rounding:
    >
    >marck@woozle:/tmp/tsostik> uname -r
    >4.10-STABLE
    >marck@woozle:/tmp/tsostik> gcc -v
    >Using builtin specs.
    >gcc version 2.95.4 20020320 [FreeBSD]
    >
    >marck@woozle:/tmp/tsostik> cat x.c
    >#include <stdio.h>
    >int main ()
    >{
    > float a;
    > for(a=0.01;a<=0.1; a+=0.01)
    > printf("%f %.3f %d\n", a*100, a*100, (int)(a*100));
    >
    >
    I believe this should more correct:
    printf ("%f %.3f %d\n", a*100, a*100, (int)(a*100+.5));

    rik

    >return 0;
    >}
    >marck@woozle:/tmp/tsostik> cc x.c
    >marck@woozle:/tmp/tsostik> ./a.out
    >1.000000 1.000 0
    >2.000000 2.000 1
    >3.000000 3.000 2
    >4.000000 4.000 3
    >5.000000 5.000 5
    >6.000000 6.000 6
    >7.000000 7.000 7
    >8.000000 8.000 7
    >9.000000 9.000 8
    >9.999999 10.000 9
    >
    >Any comments?
    >
    >
    >Sincerely,
    >D.Marck [DM5020, MCK-RIPE, DM3-RIPN]
    >------------------------------------------------------------------------
    >*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
    >------------------------------------------------------------------------
    >_______________________________________________
    >freebsd-hackers@freebsd.org mailing list
    >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    >
    >
    >
    >

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Scott Long: "[REMINDER] Call for FreeBSD status reports"

    Relevant Pages

    • Re: Weird problem
      ... size_t would be better than int, ... > The strange thing is that lim doesn't seem to control anything at all. ... Here is a possible rework of your code. ...
      (comp.lang.c)
    • Re: [PATCH 1/3] Fix COW D-cache aliasing on fork
      ... situations that only happen when you fork() from a _threaded_ environment, ... program is neither very unlikely or strange. ... int main ... pid_t pid; ...
      (Linux-Kernel)
    • Re: 010 is 8 and not 10 :(
      ... karthikbalaguru wrote: ... I find that numbers beginning with a zero are evaluated in base 8. ... int numbers= {001, ... not as 10:(Strange:(:( ...
      (comp.lang.c)
    • Re: Visual C++ 6.0 Compiler Problem with Optimizations Switched On !!
      ... if one compiles the source code attached below in the ... inline int ReturnInt1() ... I also run into some strange optimisation problems couple of times. ...
      (microsoft.public.vc.language)
    • Re: [PATCH] O9int for interactivity
      ... >> Strange your activatefunction in O9. ... >> So here is a very simple trouble maker. ... int main ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)