Floating point exception

1999-10-24 Thread Juergen Leising

Hi,

sorry for sending as root -

mutt is not able to send any messages if /var/spool/mail/account
contains 16383 messages. After writing a mail I do not get the
usual "composing" menu, instead I face a

    floating point exception

Is there a way to cope with this?

I would like to keep my mails in /var/spool/mail/account,
I do not want to move them to mbox or something like that.

But if account gets too big: What can I do?

Many thanks, Juergen.


-- 
*
* Juergen Leising, Germanyhttp://leising.home.pages.de/ *
* [EMAIL PROTECTED]  http://leising.freeshell.org/ *
*



Re: Floating point exception

1999-10-25 Thread Vincent Lefevre

On Sun, Oct 24, 1999 at 23:55:11 +0200, Juergen Leising wrote:
> mutt is not able to send any messages if /var/spool/mail/account
> contains 16383 messages. After writing a mail I do not get the
> usual "composing" menu, instead I face a
> 
>   floating point exception

A floating point exception?

After grepping *.{c,h}, it seems that Mutt doesn't use FP, except in
sendlib.c here:

/* Determine which encoding is smaller  */
if (1.33 * (float)(info->lobin+info->hibin+info->ascii) < 3.0 * (float) 
(info->lobin + info->hibin) + (float)info->ascii)

BTW, why is there a cast to float? A cast to double (or nothing) would
IMHO be more efficient, as 1.33 and 3.0 are doubles.

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - PhD student in Computer Science
Web: <http://www.vinc17.org/> or <http://www.ens-lyon.fr/~vlefevre/> - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.



Re: Floating point exception

1999-10-25 Thread Thomas Roessler

On 1999-10-25 12:33:49 +0200, Vincent Lefevre wrote:

> A floating point exception?

A common result of dividing by zero, even with integers.

[roessler@sobolev ~]$ echo "main () { return 1/0; }" > a.c
[roessler@sobolev ~]$ cc a.c
[roessler@sobolev ~]$ ./a.out
zsh: floating point exception (core dumped)  ./a.out

-- 
http://www.guug.de/~roessler/




Re: Floating point exception

1999-10-25 Thread Edmund GRIMLEY EVANS

> After grepping *.{c,h}, it seems that Mutt doesn't use FP, except in
> sendlib.c here:
> 
> /* Determine which encoding is smaller  */
> if (1.33 * (float)(info->lobin+info->hibin+info->ascii) < 3.0 * (float) 
>(info->lobin + info->hibin) + (float)info->ascii)
> 
> BTW, why is there a cast to float? A cast to double (or nothing) would
> IMHO be more efficient, as 1.33 and 3.0 are doubles.

You shouldn't be using floating-point at all for a simple calculation
like that. I bet you don't really mean "1.33" anyway. What's wrong
with ((info->lobin + info->hibin + info->ascii)*4/3 < (info->lobin +
info->hibin)*3 + info->ascii)?

On an unrelated gripe: would it be a good idea to replace all
references to ctype functions, such as isspace, by a mutt function or
macro that doesn't depend on the locale? The definitions in RFC-822,
etc aren't supposed to depend on the locale.

Edmund



Re: Floating point exception

1999-10-25 Thread Vincent Lefevre

On Mon, Oct 25, 1999 at 13:05:16 +0100, Edmund GRIMLEY EVANS wrote:
> You shouldn't be using floating-point at all for a simple calculation
> like that. I bet you don't really mean "1.33" anyway. What's wrong
> with ((info->lobin + info->hibin + info->ascii)*4/3 < (info->lobin +
> info->hibin)*3 + info->ascii)?

And you could avoid the division with:

  (info->lobin + info->hibin + info->ascii)*4
< ((info->lobin + info->hibin)*3 + info->ascii)*3

or

  info->ascii * 4 < (info->lobin + info->hibin) * 5 + info->ascii * 3

:)

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - PhD student in Computer Science
Web:  or  - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.



Re: Floating point exception

1999-10-25 Thread David DeSimone

Vincent Lefevre <[EMAIL PROTECTED]> wrote:
>
> And you could avoid the division with:
> 
>   (info->lobin + info->hibin + info->ascii)*4
> < ((info->lobin + info->hibin)*3 + info->ascii)*3

But then you risk integer overflow.  Which the division helps avoid, and
in fact, floating-point helps avoid it even more.  :)

But if you're attaching files that big... errf..  :)

-- 
David DeSimone   | "The doctrine of human equality reposes on this:
[EMAIL PROTECTED]   |  that there is no man really clever who has not
Hewlett-Packard  |  found that he is stupid." -- Gilbert K. Chesterson
UX WTEC Engineer |PGP: 5B 47 34 9F 3B 9A B0 0D  AB A6 15 F1 BB BE 8C 44



Re: Floating point exception

1999-10-25 Thread Vincent Lefevre

On Mon, Oct 25, 1999 at 17:00:29 -0500, David DeSimone wrote:

> >   (info->lobin + info->hibin + info->ascii)*4
> > < ((info->lobin + info->hibin)*3 + info->ascii)*3
> 
> But then you risk integer overflow.

If this is the case, with the other integer version too...

>  Which the division helps avoid,

Not much. The division is performed after the *4. The only difference
is the second member. But given the fact that both members have the
same order of magnitude...

> and
> in fact, floating-point helps avoid it even more.  :)

Yes, but anyway, if there is any risk with the integer versions,
I think that many variables shouldn't have type long any more.

> But if you're attaching files that big... errf..  :)

I think that something like a crash with such files would be a good
feature preserving the netiquette. :)

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - PhD student in Computer Science
Web:  or  - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.



Re: Floating point exception

1999-10-25 Thread John E. Davis

David DeSimone <[EMAIL PROTECTED]> wrote:
>> And you could avoid the division with:
>> 
>>   (info->lobin + info->hibin + info->ascii)*4
>> < ((info->lobin + info->hibin)*3 + info->ascii)*3
>
>But then you risk integer overflow.  Which the division helps avoid, and
>in fact, floating-point helps avoid it even more.  :)

Perhaps

4 * info->ascii < 5 * (info->lobin + info->hibin)

would be better.  In fact, divide both sides by 5.0 to yield:
  
(4*info->ascii)/5.0  < info->lobin + info->hibin

Then use:

   (4x)/5.0 = x - x/5 - (x%5)/5.0

and note that since 0 <= (x%5)/5.0 < 1, it follows that

 0 <= x - x/5 - (4x)/5 < 1
or
 (4x)/5.0 <= x - x/5 < 1 + (4x)/5.0
or
 x - x/5 - 1 < (4x)/5.0 <= x - x/5

So, to avoid possible integer overflow, use the test:

info->ascii - info->ascii/5 < info->lobin + info->hibin

The analysis for info->ascii < 0 is left to the reader.

--John



Floating point exception - gdb

1999-10-27 Thread Juergen Leising

Ok,

I'm not that familiar with gdb, but anyway -
this is the output of "gdb mutt core":

(...)
Core was generated by `mutt'.
Program terminated with signal 8, Floating point exception.
Reading symbols from /usr/lib/libncurses.so.4...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from /lib/libnss_files.so.1...done.
#0  0x806b7ab in menu_check_recenter (menu=0x8e20fe8) at menu.c:287
287   menu->top += menu->pagelen * ((menu->current - menu->top)
/ menu->pagelen);



Please tell me if you want to get further information; in this case
I presumably need instructions how to use gdb.

Bye, Juergen.





-- 
*
* Juergen Leising, Germanyhttp://leising.home.pages.de/ *
* [EMAIL PROTECTED]  http://leising.freeshell.org/ *
*



Re: Floating point exception - gdb

1999-10-27 Thread Chris Costello

On Thu, Oct 28, 1999, Juergen Leising wrote:
> #0  0x806b7ab in menu_check_recenter (menu=0x8e20fe8) at menu.c:287
> 287   menu->top += menu->pagelen * ((menu->current - menu->top)
> / menu->pagelen);

   Try these:

print menu
print menu->pagelen
print menu->current
print menu->top
print menu->pagelen

-- 
|Chris Costello <[EMAIL PROTECTED]>
|Machine independent code isn't.
`--



Re: Floating point exception - gdb

1999-10-28 Thread John E. Davis

Chris Costello <[EMAIL PROTECTED]> wrote:
>print menu
>print menu->pagelen
>print menu->current
>print menu->top
>print menu->pagelen

I think that you can also use:

   (gdb) p menu
   (gdb) p *menu

--John



Re: Floating point exception - gdb

1999-10-31 Thread Juergen Leising

On Wed, Oct 27, 1999 at 06:21:57PM -0500, Chris Costello wrote:
> On Thu, Oct 28, 1999, Juergen Leising wrote:
> > #0  0x806b7ab in menu_check_recenter (menu=0x8e20fe8) at menu.c:287
> > 287   menu->top += menu->pagelen * ((menu->current - menu->top)
> > / menu->pagelen);
> 
>Try these:
> 
> print menu
> print menu->pagelen
> print menu->current
> print menu->top
> print menu->pagelen
> 

yeah, this is the output:

#0  0x806b7ab in menu_check_recenter (menu=0x8e506e8) at menu.c:287
287   menu->top += menu->pagelen * ((menu->current - menu->top)
/ menu->pagelen);
(gdb) print menu
$1 = (MUTTMENU *) 0x8e506e8
(gdb) print menu->pagelen
$2 = 0
(gdb) print menu->current
$3 = 0
(gdb) print menu->top
$4 = 0
(gdb) print menu->pagelen
$5 = 0
(gdb) print *menu
$6 = {title = 0x809268e "Compose", 
  help = 0xbfffe9bc "y:Send  q:Abort  t:To  c:CC  s:Subj  a:Attach file
d:Descrip  ?:Help", data = 0x8e50578, current = 0, max = 1, redraw = 1,
menu = 2, 
  offset = 12, pagelen = 0, tagprefix = 0, make_entry = 0x8051fe8
, 
  search = 0, tag = 0x807a7c0 , 
  color = 0x806c148 , top = 0, oldcurrent = 0, searchBuf
= 0x0, 
  searchDir = 0, tagged = 0}
(gdb)


h, ok - and would you please explain this to me?
I presumably have to do something to avoid those zeroes - does it matter
which kind of terminal I use? xterm, nxterm, rxvt are the most common
ones
on my computer

By the way: I have tried several 1.0-pre-x versions 
and 1.0-release and some older ones
(0.95.5i for example is my current mutt)

- but with no better results;

Many thanks for your help,

bye, bye, Juergen.




-- 
*
* Juergen Leising, Germanyhttp://leising.home.pages.de/ *
* [EMAIL PROTECTED]  http://leising.freeshell.org/ *
*