🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.os.linux.mandrake
Article #515

Re: Problems with float variables in C

#515
From: Erik Max Francis
Date: Thu, 06 Sep 2001 03:23
25 lines
2496 bytes
Rishabh Gupta wrote:

>     I've been getting really strange results in my program when I use
> very
> small float values. For example, I check for 0.0 in case of division
> by zero
> errors but I still get the error. I also get other strange results
> like -0.0000...... (although I'm guessing that its just not displaying
> all
> the digits)

Floating point numbers are not exact, and have some peculiarites (like
having both a positive and a negative zero).  If you use them, you need
to keep this in mind when manipulating them or you will be subject to
round-off errors and inaccuracies in printing them.

-- 
 Erik Max Francis / max@alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Never had very much to say / Laugh last, laugh longest
\__/ Des'ree
    Kepler's laws / http://www.alcyone.com/max/physics/kepler/
 A proof of Kepler's laws.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net
Technical Details
Message-ID: <clcm-20010905-0009@plethora.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!news-out.visi.com!hermes.visi.com!gemini.plethora.net.POSTED!not-for-mail
References: <clcm-20010905-0003@plethora.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,898a7d80327816b3
X-Google-Attributes: gid11318c,public
X-Google-Thread: 108717,898a7d80327816b3
X-Google-Attributes: gid108717,public
X-Google-Thread: f65d0,898a7d80327816b3
X-Google-Attributes: gidf65d0,public
X-Google-Thread: f8a83,898a7d80327816b3
X-Google-Attributes: gidf8a83,public
X-Google-Thread: 100850,77ebfbc06b0f9856
X-Google-Attributes: gid100850,public
X-Google-ArrivalTime: 2001-09-05 20:23:59 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!news-out.visi.com!hermes.visi.com!gemini.plethora.net.POSTED!not-for-mail
Subject: Re: Problems with float variables in C
Approved: clc@plethora.net
Content-Transfer-encoding: 7bit
References: <clcm-20010905-0003@plethora.net>
From: Erik Max Francis <max@alcyone.com>
Organization: Alcyone Systems
X-Accept-language: en, eo
Return-Path: <news@rn.area.com>
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: alt.os.linux.mandrake,comp.lang.c.moderated,comp.programming,gnu.gcc,gnu.gcc.help
Message-ID: <clcm-20010905-0009@plethora.net>
X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.16 i686)
Originator: clcm@plethora.net (Comp Lang C'Moderated)
Date: 06 Sep 2001 03:23:45 GMT
Lines: 25
NNTP-Posting-Host: 1da7853f.news.plethora.net
X-Trace: 999746625 gemini.plethora.net 331 clcm@205.166.146.1
X-Complaints-To: abuse@plethora.net