Re: gcc strangeness

2004-07-11 Thread Bruce R. Montague

 Hi, re:

 >one of my friends has raisen very strange issue regarding gcc rounding:

 >   printf("%f %.3f %d\n", a*100, a*100, (int)(a*100));
 >
 > 9.99 10.000 9



 Hasty unresearched guess: 

 If you print with a large fp fmt (say 22.18)
you will get a better idea of the value:

 9.99403953552246 10.000 9
 
 
The "%.3f" says to round upward to inf after 3 decimal
places, so "9." is rounded to "10.000".
 
The "%f" defaults to round up after 6 decimal places,
so "9.994" is rounded to ""9.99".
 
Everything is working.
 
There are a lot of subtleties in floating-point
printf(). Printing binary values out and reading them
back accurately can be a non-trivial exercise.
 

 - bruce
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: gdb 6.1.1: File format not recognized

2004-07-11 Thread Willem Jan Withagen
Use gdb6 from the ports.

gdb6 -k .

--WjW

- Original Message - 
From: "Matthias Schuendehuette" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 10, 2004 8:36 PM
Subject: gdb 6.1.1: File format not recognized


> Hello,
>
> I tried to look into a core dump from a -current kernel with
> 'gdb' but all i get is:
>
> --8><-
> [EMAIL PROTECTED] - /var/crash
> 504 # gdb kernel.debug vmcore.0
> GNU gdb 6.1.1 [FreeBSD]
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
are
> welcome to change it and/or distribute copies of it under certain
conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
details.
> This GDB was configured as "i386-marcel-freebsd"...
> "/var/crash/vmcore.0" is not a core dump: File format not recognized
> (gdb) quit
> --8><-
>
> I looked at the man-pages of gdb(1), savecore(8) and into the
> 'Developers Handbook' but I didn't find anything about the
> correct file format of a core dump.
>
> If I look at /var/crash/info.0, there's:
>
> --8><-
> Good dump found on device /dev/da0s1b
>   Architecture: i386
>   Architecture version: 1
>   Dump length: 268369920B (255 MB)
>   Blocksize: 512
>   Dumptime: Sat Jul 10 19:40:30 2004
>   Hostname: current.best-eng.de
>   Versionstring: FreeBSD 5.2-CURRENT #5: Sat Jul 10 12:37:27 CEST 2004
> [EMAIL PROTECTED]:/raid/obj/usr/src/sys/CURRENT
>   Panicstring: unmount: dangling vnode
>   Bounds: 0
> --8><-
>
> Did I overlook something? Has someone a pointer or hint for me?
>
>
> -- 
> Ciao/BSD - Matthias
>
> Matthias Schuendehuette , Berlin (Germany)
> PGP-Key at  and  ID: 0xDDFB0A5F
> ___
> [EMAIL PROTECTED] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"
>
>

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: gcc strangeness

2004-07-11 Thread Dmitry Morozovsky
On Sun, 11 Jul 2004, Dimitry Andric wrote:

DA> > 1.00 1.000 0
DA> > 2.00 2.000 1
DA> > 3.00 3.000 2
DA> > 4.00 4.000 3
DA> > 5.00 5.000 5
DA> > 6.00 6.000 6
DA> > 7.00 7.000 7
DA> > 8.00 8.000 7
DA> > 9.00 9.000 8
DA> > 9.99 10.000 9
DA>
DA> Yes, this is completely normal if you use IEEE floating point, due to
DA> decimal <-> binary conversion and other accumulating rounding errors.
DA> In other words, floating point calculations will almost never be
DA> exact...
DA>
DA> This is not a gcc problem.  In fact, I can even reproduce your output
DA> under Windows using a Microsoft C compiler! :)

Wow, it's interesting for us to have exact step-by-step instructions for that!
;)

Sincerely,
D.Marck [DM5020, MCK-RIPE, DM3-RIPN]

*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- [EMAIL PROTECTED] ***

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: gcc strangeness

2004-07-11 Thread Dimitry Andric
On 2004-07-11 at 19:06:32 Dmitry Morozovsky wrote:

> 1.00 1.000 0
> 2.00 2.000 1
> 3.00 3.000 2
> 4.00 4.000 3
> 5.00 5.000 5
> 6.00 6.000 6
> 7.00 7.000 7
> 8.00 8.000 7
> 9.00 9.000 8
> 9.99 10.000 9

Yes, this is completely normal if you use IEEE floating point, due to
decimal <-> binary conversion and other accumulating rounding errors.
In other words, floating point calculations will almost never be
exact...

This is not a gcc problem.  In fact, I can even reproduce your output
under Windows using a Microsoft C compiler! :)


pgpniUit3rNUP.pgp
Description: PGP signature


gcc strangeness

2004-07-11 Thread Dmitry Morozovsky
Dear colleagues,

one of my friends has raisen very strange issue regarding gcc rounding:

[EMAIL PROTECTED]:/tmp/tsostik> uname -r
4.10-STABLE
[EMAIL PROTECTED]:/tmp/tsostik> gcc -v
Using builtin specs.
gcc version 2.95.4 20020320 [FreeBSD]

[EMAIL PROTECTED]:/tmp/tsostik> cat x.c
#include 
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));
return 0;
}
[EMAIL PROTECTED]:/tmp/tsostik> cc x.c
[EMAIL PROTECTED]:/tmp/tsostik> ./a.out
1.00 1.000 0
2.00 2.000 1
3.00 3.000 2
4.00 4.000 3
5.00 5.000 5
6.00 6.000 6
7.00 7.000 7
8.00 8.000 7
9.00 9.000 8
9.99 10.000 9

Any comments?


Sincerely,
D.Marck [DM5020, MCK-RIPE, DM3-RIPN]

*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- [EMAIL PROTECTED] ***

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


gdb 6.1.1: File format not recognized

2004-07-11 Thread Matthias Schuendehuette
Hello,

I tried to look into a core dump from a -current kernel with
'gdb' but all i get is:

--8><-
[EMAIL PROTECTED] - /var/crash
504 # gdb kernel.debug vmcore.0
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
"/var/crash/vmcore.0" is not a core dump: File format not recognized
(gdb) quit
--8><-

I looked at the man-pages of gdb(1), savecore(8) and into the
'Developers Handbook' but I didn't find anything about the
correct file format of a core dump.

If I look at /var/crash/info.0, there's:

--8><-
Good dump found on device /dev/da0s1b
  Architecture: i386
  Architecture version: 1
  Dump length: 268369920B (255 MB)
  Blocksize: 512
  Dumptime: Sat Jul 10 19:40:30 2004
  Hostname: current.best-eng.de
  Versionstring: FreeBSD 5.2-CURRENT #5: Sat Jul 10 12:37:27 CEST 2004
[EMAIL PROTECTED]:/raid/obj/usr/src/sys/CURRENT
  Panicstring: unmount: dangling vnode
  Bounds: 0
--8><-

Did I overlook something? Has someone a pointer or hint for me?


-- 
Ciao/BSD - Matthias

Matthias Schuendehuette , Berlin (Germany)
PGP-Key at  and  ID: 0xDDFB0A5F
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"