Hello all
This is a really strange problem. I have code that performs a few
calculations based on input from a joystick, and writes these values
to a file using basically the following code:
fprintf(fpResults, "i: %4.2f, j: %4.2f", i, j );
This works correctly (literally) 99.9999% of the time. However, once
every million or so writes I get the following output:
i: -1.#J, j: 1.#R
Does anybody know what this means? 2 1569
On Apr 20, 10:11 pm, danep2 <danepow...@gmail.comwrote:
This is a really strange problem. I have code that performs a few
calculations based on input from a joystick, and writes these values
to a file using basically the following code:
fprintf(fpResults, "i: %4.2f, j: %4.2f", i, j );
This works correctly (literally) 99.9999% of the time. However, once
every million or so writes I get the following output:
i: -1.#J, j: 1.#R
Does anybody know what this means?
Perhaps your compiler vendor? This can't happen in a conforming
implementation unless your code has undefined behavior. Perhaps
the vendor could indicate what sort of undefined behavior might
cause it. (It will probably depend on how floating point values
are represented.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On Apr 21, 4:18*am, James Kanze <james.ka...@gmail.comwrote:
On Apr 20, 10:11 pm, danep2 <danepow...@gmail.comwrote:
This is a really strange problem. *I have code that performs a few
calculations based on input from a joystick, and writes these values
to a file using basically the following code:
fprintf(fpResults, "i: %4.2f, j: %4.2f", i, j );
This works correctly (literally) 99.9999% of the time. However, once
every million or so writes I get the following output:
i: -1.#J, j: 1.#R
Does anybody know what this means?
Perhaps your compiler vendor? *This can't happen in a conforming
implementation unless your code has undefined behavior. *Perhaps
the vendor could indicate what sort of undefined behavior might
cause it. *(It will probably depend on how floating point values
are represented.)
--
James Kanze (GABI Software) * * * * * * email:james.ka...@gmail.com
Conseils en informatique orientée objet/
* * * * * * * * * *Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
I am developing using Microsoft Visual Studio 2005. Prior to
migrating to VS 2005, we also experienced this problem with VC++ 6.0.
For what it's worth, this *usually* happen when the values of i or j
are very close to zero. (I don't know for a fact what they are, I am
simply inferring from the data immediately surrounding this output.)
Also, usually both variables are affected - i.e., if the output for i
is corrupt, the output for j will also be corrupt. However, other
floats being written in the same statement are never corrupted. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Noah Roberts |
last post by:
There is some windows specific code in this, but I believe the issue to
be something standard so...
The problem is that after attaching the name of the subdirectory I have
something like...
|
by: Rick |
last post by:
Hi,
Sorry, I couldn't find a better title for this post. Anyway, I got a piece
of C code which only works well if I put a fprintf in it. Here's the code :
unsigned int8 Port_getPortNum( char...
|
by: Marlene Stebbins |
last post by:
Something very strange is going on here. I don't know if it's a C
problem or an implementation problem. The program reads data from
a file and loads it into two arrays. When xy, x, y, *xlist and...
|
by: Magix |
last post by:
Hi,
I want to use fprintf to write to a file. My question about the formatted
output
How can I format so that I can allocate certain width for each %s
(Left-aignlied) ?
Example:
fprintf("%s...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |