Article View: alt.comp.lang.learn.c-c++
Article #71Re: Floating point equal to Integer Value ?
From: Samantha Fox
Date: Mon, 30 Jul 2001 13:55
Date: Mon, 30 Jul 2001 13:55
35 lines
2538 bytes
2538 bytes
you can't even use == or != to compare two floats
"Alya Al Omrani" <alomrani@emirates.net.ae> wrote in message
news:9iejot$4an2@news.emirates.net.ae...
> Hi, how can i check if a floating point value is equal to integer value ?
> I tried looking of there is a function that does so but there isn't
>
> I tried doing the following
>
> /* lets say those are my values */
> int x=20;
> float x=20.0, z;
>
> z=(float)x;
> /* I used a printf staetment to check that the value of x was assigned to
z
> and it worked ! */
> printf("%f", z);
>
> /* here i want to check */
> if(z==x) /* at this instant it freezes */
> printf("values are equal");
> else
> printf("they r not euqal");
> ///////////////
>
>
> I sthere a substitue method that i can do so, i tried taking the % modulus
> of both z and x to see if it will give zero but i got same erro, the
program
> wont compile
>
>
>
Technical Details
Message-ID:
<SGd97.1487$257.47689@ozemail.com.au>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!dc1.nntp.concentric.net!sjc1.nntp.concentric.net!newsfeed.concentric.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mailReferences:
<9iejot$4an2@news.emirates.net.ae>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10b1c0,dbd8a1f951d6b446 X-Google-Attributes: gid10b1c0,public X-Google-Thread: 108717,dbd8a1f951d6b446 X-Google-Attributes: gid108717,public X-Google-Thread: 114592,dbd8a1f951d6b446 X-Google-Attributes: gid114592,public X-Google-Thread: 108b44,dbd8a1f951d6b446 X-Google-Attributes: gid108b44,public X-Google-Thread: 109fba,dbd8a1f951d6b446 X-Google-Attributes: gid109fba,public X-Google-Thread: 10d4ba,dbd8a1f951d6b446 X-Google-Attributes: gid10d4ba,public X-Google-ArrivalTime: 2001-07-30 06:55:41 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!dc1.nntp.concentric.net!sjc1.nntp.concentric.net!newsfeed.concentric.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail From: "Samantha Fox" <pamela2002@hotmail.com> Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++,comp.programming,comp.sys.lang.c++,csugrad.programming.c References: <9iejot$4an2@news.emirates.net.ae> Subject: Re: Floating point equal to Integer Value ? Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2462.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000 Message-ID: <SGd97.1487$257.47689@ozemail.com.au> NNTP-Posting-Host: 2cust108.tnt2.penrith.au.da.uu.net X-Trace: ozemail.com.au 996501298 210.84.120.108 (Mon, 30 Jul 2001 23:54:58 EST) NNTP-Posting-Date: Mon, 30 Jul 2001 23:54:58 EST Organization: OzEmail Ltd, Australia Distribution: world Date: Mon, 30 Jul 2001 23:55:10 +1000