473,808 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

isinf()

The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Oct 8 '08 #1
9 6884
Richard Tobin wrote:
The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?
It seems so to me.
Oct 8 '08 #2

"Richard Tobin" <ri*****@cogsci .ed.ac.ukwrote in message

int isinf(double x)
{
if(x DBL_MAX)
return 1;
else
return 0;
}

Oct 8 '08 #3
"Malcolm McLean" <re*******@btin ternet.comwrite s:
"Richard Tobin" <ri*****@cogsci .ed.ac.ukwrote in message

int isinf(double x)
{
if(x DBL_MAX)
return 1;
else
return 0;
}
That fails for negative infinity.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 8 '08 #4
Richard Tobin wrote:
>
The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?
Think about it. If x is not a number, what can you say about x-x?
I fail to see any way that expression could become a number.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Oct 9 '08 #5
On 8 Oct 2008 14:11:29 GMT,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?
If isnan(x) is true, then x - x is also NaN, and isnan(x - x) would also
be true.

Check Annex F to the C99 standard. Specifically, in F8.2 it is made
clear that the equivalence x - x == 0.0 does not hold when x can be NaN
or Inf.

Martien
--
|
Martien Verbruggen | I took an IQ test and the results were
| negative.
|
Oct 9 '08 #6
CBFalconer <cb********@yah oo.comwrites:
Richard Tobin wrote:
>>
The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?

Think about it. If x is not a number, what can you say about x-x?
I fail to see any way that expression could become a number.
Indeed, if x is NaN then so is x-x, so isnan(x-x) would be true. But
7.12.3.3 says "The isinf macro returns a nonzero value if and only if
its argument has an infinite value." That makes it sound as if
isinf(x) should return zero if x is NaN, since NaN does not have an
infinite value.
Oct 9 '08 #7
In article <o9***********@ news.heliotrope .home>,
Martien Verbruggen <mg**@tradingpo st.com.auwrote:
>The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?
>If isnan(x) is true, then x - x is also NaN, and isnan(x - x) would also
be true.
Exactly. And that would be wrong, because isinf(x) should be false
if x is a NaN.

Anyway, I eventually discovered that this mistake has already been
reported to the autoconf project.

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Oct 9 '08 #8
Martien Verbruggen wrote:
On 8 Oct 2008 14:11:29 GMT,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
>The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?

If isnan(x) is true, then x - x is also NaN, and isnan(x - x) would also
be true.

Check Annex F to the C99 standard. Specifically, in F8.2 it is made
clear that the equivalence x - x == 0.0 does not hold when x can be NaN
or Inf.
Exactly. Which is why isnan(x-x) doesn't make sense as an implementation
of ifinf(x). isinf(x) isn't supposed to return true when x is a NaN;
it's only supposed to return true when x is infinite.

Oct 9 '08 #9
On Thu, 09 Oct 2008 12:57:20 GMT,
James Kuyper <ja*********@ve rizon.netwrote:
Martien Verbruggen wrote:
>On 8 Oct 2008 14:11:29 GMT,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
>>The GNU Autoconf manual provides a work-around for missing isinf()
and isnan() functions, which exist in C99 and many, but not all,
pre-C99 implementations :

http://www.gnu.org/software/libtool/...rtability.html

The given definition of isinf(x) boils down to return isnan (x - x),
which will return true for NaNs. Surely this is wrong?

If isnan(x) is true, then x - x is also NaN, and isnan(x - x) would also
be true.

Check Annex F to the C99 standard. Specifically, in F8.2 it is made
clear that the equivalence x - x == 0.0 does not hold when x can be NaN
or Inf.

Exactly. Which is why isnan(x-x) doesn't make sense as an implementation
of ifinf(x). isinf(x) isn't supposed to return true when x is a NaN;
it's only supposed to return true when x is infinite.
Sorry all. I misread the isinf() as isnan(). I thought the OP was
confused about why isnan(x-x) returned true.

Martien
--
| Yes; Windows is great for running &
Martien Verbruggen | developing viruses, for instance. It's also
| very popular, but then again, so is the
| common cold. -- Dave Hinz
Oct 9 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

61
8676
by: norb1 | last post by:
After tracking down a bug in my Fortran program, I found that it assumed max(NaN,0.) = 0. This makes no sense, as the outcome of the operation is undefined and should be NaN. max(NaN,0.) = NaN After researching, it appears the first outcome is accepted behavior, and might be included in the revised IEEE 754 standard, which affects
2
49867
by: Priya | last post by:
Halo. I am using isinf() & isnan() in my code, and i get an error error LNK2001: unresolved external symbol "int __cdecl isnan(double)" (?isnan@@YAHN@Z) my code is the implementation of LambertW function #include <math.h>
10
106365
by: zl2k | last post by:
hi, Can someone let me know the command to check if a value is inf or NaN in c++? I am using gcc in linux. Thanks for help. zl2k
12
2574
by: horacius.rex | last post by:
Hi, I have a code that in some part of the program calculates 1/x for a lot of different x's. About 1 of 100 times x is equal to zero, so when I print the result I obtain inf. I wonder if there is a way to detect this "infinity" and convert it to the float zero. I mean something like for i = .... calculate 1/x_i
3
3348
by: newbie1123 | last post by:
Hi! I am using Borland c++ builder version 6.0 and when I compile a program containing isinf() (I did include math.h) I get 'call to undefined function isinf'. Anyone knows what is wrong? Thanks
16
5660
by: istillshine | last post by:
In my code I used NAN and isnan(x). I found they were convenient to use. I also noticed that older C standard does not support NAN and isnan(x). When I compiled my program using: gcc -Wall -c it was fine.
9
9952
by: void main | last post by:
I'm rather new to complex numbers in C and was wondering, how do I initialize a complex variable properly if the imaginary part is 0. I tried -------- #include <complex.h> float complex c = 1.0f; --------
3
3374
by: MM | last post by:
Hi to all, I'm trying to import a tab separated values file onto Excel with the following script: import csv from pyExcelerator import * w = Workbook() worksheet = w.add_sheet('sim1')
8
3636
by: john.goodleaf | last post by:
I'm poking at writing data out to a SAS XPORT file (transport file). Each record must be 80 bytes long, ASCII. Integers should be "IBM- style integers" and floats should be "IBM-style doubles." Now I have some idea what that means from reading a C source file documented by the SAS institute, but before I go over the deep end trying to write my own routines, does anyone know of an already-done means of writing integers and floats out to...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.