Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Unexpected ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 11 of 14 Topic 45880 of 47034
Post > Topic >>

Re: Unexpected results while working with floats

by Greg Herlihy <greghe@[EMAIL PROTECTED] > May 13, 2008 at 02:50 AM

On May 13, 2:04=A0am, Lionel B <m...@[EMAIL PROTECTED]
> wrote:
> On Tue, 13 May 2008 08:55:23 +0000, Lionel B wrote:
> > On Mon, 12 May 2008 16:02:54 -0700, Greg Herlihy wrote:
>
> >> On May 12, 3:08=A0pm, Lionel B <m...@[EMAIL PROTECTED]
> wrote:
>
> >>> On my system (compiler GCC 4.1.2) with
>
> >>> =A0 float f =3D 139.4;
>
> >>> and compiled with:
>
> >>> =A0 g++ -std=3Dc++98 -pedantic -Wall -Wextra
>
> >>> I get no warnings and the output is 'Expected result'. Should the
> >>> compiler warn if there's an implicit conversion? Or only if it
results=

> >>> in loss of precision?
>
> >> The g++ compiler can issue a warning if you want one:
>
> >> =A0 =A0g++ -Wshorten-64-to-32
>
> > cc1plus: error: unrecognized command line option "-Wshorten-64-to-32"
>
> > GCC 4.3.0 on x86_64
>
> > Anyway, that doesn't sound like a floating-point warning...
>
> This does it: -Wconversion. With
>
> =A0 float f =3D 139.4;
>
> warning: conversion to =91float=92 alters =91double=92 constant value

On my machine, using gcc (version 4.2.1 (Apple Inc. build 5559)) -
Wconversion re****ts nothing.
Whereas -Wshorten-64-to-32 re****ts:

   warning: implicit conversion shortens 64-bit value into a 32-bit
value

Greg
 




 14 Posts in Topic:
Unexpected results while working with floats
bintom <binoythomas110  2008-05-12 08:09:47 
Re: Unexpected results while working with floats
Lionel B <me@[EMAIL PR  2008-05-12 15:23:03 
Re: Unexpected results while working with floats
bintom <binoythomas110  2008-05-12 08:59:36 
Re: Unexpected results while working with floats
"Victor Bazarov"  2008-05-12 12:38:44 
Re: Unexpected results while working with floats
=?UTF-8?B?RXJpayBXaWtzdHL  2008-05-12 16:42:20 
Re: Unexpected results while working with floats
Lionel B <me@[EMAIL PR  2008-05-12 16:33:21 
Re: Unexpected results while working with floats
Lionel B <me@[EMAIL PR  2008-05-12 22:08:09 
Re: Unexpected results while working with floats
Greg Herlihy <greghe@[  2008-05-12 16:02:54 
Re: Unexpected results while working with floats
Lionel B <me@[EMAIL PR  2008-05-13 08:55:23 
Re: Unexpected results while working with floats
Lionel B <me@[EMAIL PR  2008-05-13 09:04:36 
Re: Unexpected results while working with floats
Greg Herlihy <greghe@[  2008-05-13 02:50:53 
Re: Unexpected results while working with floats
Lionel B <me@[EMAIL PR  2008-05-13 10:11:49 
Re: Unexpected results while working with floats
Juha Nieminen <nospam@  2008-05-13 16:43:14 
Re: Unexpected results while working with floats
bintom <binoythomas110  2008-05-14 09:19:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:38:08 CDT 2008.