From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19589 invoked by alias); 4 Feb 2008 20:32:10 -0000 Received: (qmail 19580 invoked by uid 22791); 4 Feb 2008 20:32:09 -0000 X-Spam-Check-By: sourceware.org Received: from londo.lunn.ch (HELO londo.lunn.ch) (80.238.139.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 04 Feb 2008 20:31:52 +0000 Received: from lunn by londo.lunn.ch with local (Exim 3.36 #1 (Debian)) id 1JM7yg-00035T-00; Mon, 04 Feb 2008 21:31:42 +0100 Date: Mon, 04 Feb 2008 20:32:00 -0000 From: Andrew Lunn To: "Davies, Greg" Cc: ecos-discuss@ecos.sourceware.org Message-ID: <20080204203142.GJ31597@lunn.ch> Mail-Followup-To: "Davies, Greg" , ecos-discuss@ecos.sourceware.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] NAN X-SW-Source: 2008-02/txt/msg00006.txt.bz2 On Mon, Feb 04, 2008 at 02:19:39PM -0400, Davies, Greg wrote: > Hi, > I'm trying to compile a program that assigns the value NAN to > some floats to indicate that no real data has come out of a sensor yet. > My problem is that I can't find a header that defines NAN. I used math.h > when I was writing this class the first time around. I even tried using > numeric_limits::quiet_NaN() from but everything I try > gives me an error along the lines of: NAN is not declared in this scope. > > > Could there be something I'm missing from the eCos configuration do add > a header that defines NAN? All help is greatly appreciated. I could not find anywhere in the sources where NAN is defined. Interesting isnan() is available, but it uses hard coded values. According to C99 it should be in . I wounder if the problem is to do with none-signalling NAN against signalling NAN. NAN should have a value which does not cause a floating point exception to be raised. But that is architecture dependent. So maybe the HAL needs to define it. That is messy, so maybe it has just been left out. So you probably need to declare it yourself. This should help you figure out the value: int isnan(double x) { int hx,lx; hx = (CYG_LIBM_HI(x)&0x7fffffff); lx = CYG_LIBM_LO(x); hx |= (unsigned)(lx|(-lx))>>31; hx = 0x7ff00000 - hx; return ((unsigned)(hx))>>31; } Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss