473,883 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mysterious -1.#INF without division!

1 New Member
Hi,

I wrote a program to translate a binary file (for which I have the text version) into another binary file (I needed a new format) and text file. There is no division involved, just some nested loops with data being transferred from one buffer to another, to simplify the creation of the desired output files.
The outer (main) loop functions properly 9,947 times and then 'something' happens in the middle of an interior loop, causing all subsequent output to the text file to be -1.#INF00 (i.e. negative infinity). All of the output prior to this point matches the original textfile exactly. I perform a static_cast from type double to type float for each transfer of data in this loop, and I realize that floating point errors can cause 1.#INF to occur, but I see no reason why this should afflict my program.
The input that trips the infinity bug is -1.356217...far from negative infinity. Could this be fixed with something like _fpreset or _control87? If anyone knows what is happening or how to fix/avoid this infinite mystery, I would appreciate the help. Thanks.

Phil
Aug 8 '07 #1
1 2395
gpraghuram
1,275 Recognized Expert Top Contributor
Hi,

I wrote a program to translate a binary file (for which I have the text version) into another binary file (I needed a new format) and text file. There is no division involved, just some nested loops with data being transferred from one buffer to another, to simplify the creation of the desired output files.
The outer (main) loop functions properly 9,947 times and then 'something' happens in the middle of an interior loop, causing all subsequent output to the text file to be -1.#INF00 (i.e. negative infinity). All of the output prior to this point matches the original textfile exactly. I perform a static_cast from type double to type float for each transfer of data in this loop, and I realize that floating point errors can cause 1.#INF to occur, but I see no reason why this should afflict my program.
The input that trips the infinity bug is -1.356217...far from negative infinity. Could this be fixed with something like _fpreset or _control87? If anyone knows what is happening or how to fix/avoid this infinite mystery, I would appreciate the help. Thanks.

Phil
Hi,
float cannot hold a double value and u are getting the error becos of this issue.
Try to use double itself to hold and print vale to new file if it is acceptable in your design.

Raghuram
Aug 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
10170
by: Gustav Lead | last post by:
Hi all, I have trouble reading back floating point data from a file. It appears as if the tokens for positive and negative infinity (1.#INF and -1.#INF) that my implementation writes get misinterpreted (to 1.0 and -1.0) when I try to read them back in. #include <fstream> #include <limits>
13
2452
by: Max | last post by:
Hi There! I'm having a mysterious error right after I login using Forms Authentication in my ASP.NET app. Below is the error... Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. The exception throws at the code that tries to set a property (String data type) at my Menu user control.
55
8359
by: Martin Jørgensen | last post by:
Hi, I found the code below from http://www.blitzbasic.com/Community/posts.php?topic=55633 ------ ' Check if number is finite. Local u:Double = 2 ' also works for floats
1
2350
by: Peter Knörrich | last post by:
Hello, I've found another inconsistency, and looking through the list archives I can find mentions of funky stuff like print float('inf') giving Infanity
94
11562
by: krypto.wizard | last post by:
Last month I appeared for an interview with EA sports and they asked me this question. How would you divide a number by 7 without using division operator ? I did by doing a subtraction and keeping a counter that kept a tab on how many times I subtracted. Later, the EA sport guy told me that of course there are can be better technique by using bit operator.
2
2655
by: Martin Manns | last post by:
Hi, I am experiencing some trouble with gmpy v1.01. Multiplying an mpq with inf results in a floating point exception that exits python. Has this already been fixed in newer gmpy versions? ~ $ python Python 2.4.3 (#1, Mar 26 2007, 00:32:54) on linux2 Type "help", "copyright", "credits" or "license" for more information.
4
2468
by: Joshua J. Kugler | last post by:
I'm trying to put some values into a struct. Some of these values are NaN and Inf due to the nature of the data. As you well may know, struct (and other things) in Python <= 2.4 doesn't support inf and nan float values. You get the dreaded "SystemError: frexp() result out of range" error. Before I go and write my own little wrapper, has anyone out there written an "extended" struct that supports the inf and nan values? I know this is...
0
9792
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
11142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10848
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
10417
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9575
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...
0
7130
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();...
0
5798
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3234
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.