What does floating point error -1.#J mean?
2011-11-02 20:15
323 查看
What does floating point error -1.#J mean?
up vote 4 down vote favorite share [fb] share [tw] | Recently, sometimes (rarely) when we export data from our application, the export log contains float values that look like "-1.#J". I haven't been able to reproduce it so I don't know what the float looks like in binary, or how Visual Studio displays it. I tried looking at the source code for printf, but didn't find anything (not 100% sure I looked at the right version though...). I've tried googling but google throws away any #, it seems. And I can't find any lists of float errors. c++ c floating-point printf
| ||
|
1 Answer
activeoldestvotesup vote 14 down voteaccepted | It can be either negative infinity or NaN (not a number). Due to the formatting on the field printf does not differentiate between them. I tried the following code in Visual Studio 2008: double a = 0.0; printf("%.3g\n", 1.0 / a); // +inf printf("%.3g\n", -1.0 / a); // -inf printf("%.3g\n", a / a); // NaN which results in the following output: 1.#J -1.#J -1.#J removing the .3 formatting specifier gives: 1.#INF -1.#INF -1.#IND so it's clear 0/0 gives NaN and -1/0 gives negative infinity (NaN, -inf and +inf are the only "erroneous" floating point numbers, if I recall correctly) |
相关文章推荐
- What does "Error: L6248E: cannot have address type relocation" mean?
- What does the first letter "c" mean in "calloc"?
- What Does “Neurons that Fire Together Wire Together” Mean?
- What does TCP Zero Window mean?
- What does ^M character mean in Vim?
- Discussion1: What does mandatory/required variable in a query mean?
- What exactly does “variable initializer is redundant” mean?
- What does it mean by rendering of page in JSF
- What floating point types are available in .NET?
- Error: does not contain a static 'Main' method suitable for an entry point [wpf]
- What does backend type static mean in Magento?
- what does “exited abnormally with signal 9: Killed: 9” mean
- WPF error: does not contain a static 'Main' method suitable for an entry point
- ${1+"$@"}是什么意思 (What does ${1+"$@"} mean)?
- What does “=>” mean in import in scala?(转自StackOverflow问答)
- What does information_schema.TABLES.DATA_FREE mean in MySQL?
- (Kattis - heritage)What Does It Mean?(map+记忆话搜索)(补)
- (转载)What does (Aborted) mean in HttpWatch?
- java classpath: what does it mean?
- What does "exceeded limit of maxWarmingSearchers=X" mean?