* gcc: Floating point exception
@ 2005-02-20 20:58 J.
2005-02-20 21:05 ` Jan-Benedict Glaw
0 siblings, 1 reply; 3+ messages in thread
From: J. @ 2005-02-20 20:58 UTC (permalink / raw)
To: linux-c-programming
Sunday, February 20 21:50:07
Hello,
When I compile the following 5lines of code with `gcc -Wall -pedantic', I
get no warnings or any errors. However when I run the compiled
program I get the error: Floating point exception .
Anyone knows what I should fix ? I already tryd the different
storage types float, etc.. But then gcc complains warning: long int
format, int arg... etc... ?
I am using gcc version: 2.95.4
#include <stdio.h>
int main(void) {
int red = 0;
int green = 128;
int blue = 0;
printf("%d %d %d\n", (100 / (256 / red)),
(100 / (256 / green)), (100 / (256 / blue)));
return 0;
}
Thnkx.. J.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gcc: Floating point exception
2005-02-20 20:58 gcc: Floating point exception J.
@ 2005-02-20 21:05 ` Jan-Benedict Glaw
2005-02-20 21:13 ` J.
0 siblings, 1 reply; 3+ messages in thread
From: Jan-Benedict Glaw @ 2005-02-20 21:05 UTC (permalink / raw)
To: linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 717 bytes --]
On Sun, 2005-02-20 21:58:54 +0100, J. <mailing-lists@xs4all.nl>
wrote in message <Pine.LNX.4.21.0502202150070.2008-100000@hestia>:
> int red = 0;
> int green = 128;
> int blue = 0;
>
> printf("%d %d %d\n", (100 / (256 / red)),
> (100 / (256 / green)), (100 / (256 / blue)));
With red = blue = 0, you're having two divisions by zero. That won't
fly...
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gcc: Floating point exception
2005-02-20 21:05 ` Jan-Benedict Glaw
@ 2005-02-20 21:13 ` J.
0 siblings, 0 replies; 3+ messages in thread
From: J. @ 2005-02-20 21:13 UTC (permalink / raw)
To: linux-c-programming
On Sun, 20 Feb 2005, Jan-Benedict Glaw wrote:
> On Sun, 2005-02-20 21:58:54 +0100, J. <mailing-lists@xs4all.nl>
> wrote in message <Pine.LNX.4.21.0502202150070.2008-100000@hestia>:
> > int red = 0;
> > int green = 128;
> > int blue = 0;
> >
> > printf("%d %d %d\n", (100 / (256 / red)),
> > (100 / (256 / green)), (100 / (256 / blue)));
>
> With red = blue = 0, you're having two divisions by zero. That won't
> fly...
>
> MfG, JBG
Aiii.. of course !!
Thnkx....
J.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-02-20 21:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-20 20:58 gcc: Floating point exception J.
2005-02-20 21:05 ` Jan-Benedict Glaw
2005-02-20 21:13 ` J.
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 NNTP newsgroup(s).