while storing the value 1.111 in a float variable the value stored and printed is 1.1109999. why is this loss of data or sometimes the gain of data?. |
+0 forum
2 | ||

At work we have a large number of unit tests that try to alert us that we have made changes that have broken our code. Many of these tests work by evaluating functions under known conditions and comparing the result with the known result. The known result is acquired by manually testing the newly written function with a number of conditions that should exercise all the features of it. We get the output value of the function from this test and then use that as a reference value in the unit test. Very often, a function returns a floating point … |
+0 forum
4 | ||

Hello guys, i'm trying to compute the area of a triangle using the Floating-Point stack (FPU87), but i'm having an issue outputting my value. I'm computing the area using Heron's formula: T = sqrt{s * (s - a ) * (s - b) * (s - c) } Note: s = (a+b+c) / 2 I'm outputting: s * (s - a ) * (s - b) * (s - c), from the FPU87 stack just to make sure it did the calculations correctly, but i'm getting "-nan". I know it means "not a number", but as a test I inputted … |
+0 forum
2 | ||

Hello. I wrote a program to convert decimal fraction values into binary fractions. I seem to be running into some floating point accuracy problems. After multiplying a floating point number by 2 over and over, eventually the number becomes corrupted. Since I'm multiplying so many times, I think the error occurs because the small inaccuracies of the floating point number eventually become significant. [CODE] original_num = 0.1575 num = original_num digits = [] while (num != 0): print "%f * 2 = %f" % (num, num * 2.0), num *= 2.0 if (num >= 1): num -= 1 print " … |
+0 forum
3 | ||

We know that 0.1 + 0.1 + 0.1 - 0.3 = 0.0 But in python 0.1 + 0.1 + 0.1 - 0.3 = 5.5511151231257827e-017 Is there any way I can get 0.0...?? |
+0 forum
5 | ||

Hi, i'm getting only one digit after floating point after conversion from string to float. Have tryed from standart functions to i don't know.. the problems is that conversion whatever it would be (strtod(), stringstream >> float, atof(), don't even rembember all other wacky ways to do that) brings me only one or none (if i have number.00) digits after floating point. Would be very happy to hear something that might help.. p.s. oh, if that matters - i get string from file via getline.. |
+0 forum
4 | ||

May I know how to solve floating decimal problems? |
+0 forum
1 | ||

I'm in the midst of developing a Python toolset for some proprietary hardware used at NOAO. The code has to write a series of EEPROMS in the hardware to determine conversion factors for hardware attributes. The EEPROM format is 2048 32-bit words each word represents the slope, intercept, minimum or maximum value for one of the hardware attributes. What goes into the EEPROM needs to be the binary representation in IEEE 32 bit format for the conversion factor since the eeprom is read by a 'C' program. I could write the EEPROM from a 'C' routine but I was hoping … |
+0 forum
0 | ||

How would you safely round a floating point number to the nearest integer ? Python has the built in function [icode]round[/icode], but it returns a floating point number [code=python] >>> round(4.9) 5.0 >>> help(round) Help on built-in function round in module __builtin__: round(...) round(number[, ndigits]) -> floating point number Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative. [/code] Using [icode]int(round(x))[/icode] to obtain the nearest integer looks like a bad idea because the [icode]int()[/icode] function is discontinuous near integer values, and therefore, [icode]round(x)[/icode] returns a … |
+0 forum
7 | ||

This program is intended to determine if a fractions is valid (non-zero, non-negative denominator) and to convert an improper fraction into a whole/mixed number. While running the program I get the message "Floating point exception" after it reads the inputs just inside the for loop. Any insight into what is going on and how to fix it will be greatly appreciated. [CODE]#include <iostream> #include <cstdlib> using namespace std; int main() { int num, numer, denom; // number of fractions, numerator, denominator char slash; // storage for '/' symbol. cin >> num; cout << "num= " << num << endl; for … |
+1 forum
7 | ||

Hi, i've just taken higher computing in college and need to know a couple of things before i can proceed further with the course. The first is how to represent floating point numbers in binary. i have a good grasp of binary & data types etc. there are a few problems in the book i am working on, change these denary numbers into binary using a [B][U]binary point[/U][/B]. 0.25 = 0.01 7.375 = 0111.011 15.53125 = 1111.10001 i understand the process before the point, its after the point i don't get, could someone explain the process? this lot requires floating … |
+0 forum
3 |

The End.