How do you read in a double from a file in C++?
For ints I know you can use the getline() and then atoi, but I am not finding an array to double function. What is available for reading in doubles, or converting a char array to a double?
...
I have got several thousands of lines of a web application source code, initially written on a US development system, to maintain. It makes heavy use of SQL statement strings, which are combined on the fly, e.g.
string SQL = "select * from table where double_value = " + Math.Round(double_value, 2);
Don't comment on bad programming sty...
Here's a fun one I've been trying to figure out. I have the following program:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(int argc, char *argv[])
{
string s("5");
istringstream stream(s);
double theValue;
stream >> theValue;
cout << theValue << endl;
cout << stream...
I have 3 tables I need to join. The contracts table is the main table, the 'jobs' and 'companies' table are extra info that can be associated to the contracts table.
so, since I want all entries from my 'contracts' table, and the 'jobs' and 'companies' data only if it exists, I wrote the query like this....
$sql = "SELECT * FROM contr...
I'm trying to return a double from another object then store that into a new double but i'm getting the error incompatible types in initialization. What am I missing here?
double gradePoints = 0.0;
double other = [aCourse getGradePoints];
gradePoints = gradePoints + other;
This is in my other object
- (double) getGradePoints{
retu...
both of them hold 8 bytes, but how come the max value for double is much greater than the max value of long? there is a finite number of bits available, so how could you reach greater numbers with floating point variables?
...
I have a double thats got a value of something like 0.50000 but I just want 0.5 - Is there any way to get rid of those trailing 0's? :)
...
Right now i'm trying this:
int a = round(n) ;
where n is a double but its not working. What am i doing wrong?
...
Hi, I just read that C99 has double_t which should be at least as wide as double. Does this imply that it gives more precision digits after the decimal place? More than the usual 15 digits for double?.
Secondly, how to use it: Is only including
#include <float.h>
enough? I read that one has to set the FLT_EVAL_METHOD to 2 for long ...
Hy,
I got an intersting problem which I stumbled upon. When I double-click a JLabel in a JSplitPane I want to add another jbutton in a JPanel, its a shorter way to make a dragg and drop. The problem is that the button doesn't appears only if i'll position the mouse on the area the button should appear. Why does it happens this way? Anyo...
We have 2's complement for integers that allows us to perform operations without worrying about the sign. That is a big help at the implementation level.
Similarly we have so many floating point operations and yet we rely on sign and magnitude. What is the reason?
Why can't a 2's complement like system work for floats?
...
Im trying to change from big endian to little endian on a double. One way to go is to use
double val, tmp = 5.55;
((unsigned int *)&val)[0] = ntohl(((unsigned int *)&tmp)[1]);
((unsigned int *)&val)[1] = ntohl(((unsigned int *)&tmp)[0]);
But then I get a warning: "dereferencing type-punned pointer will break strict-aliasing rules" an...
if I have a small double in vb.net like this:
dim x as double = 0.00000003
a conversion to a string would produce a E-presentation (3E-7). in debugging the value it will be shown as full number (0.00000003).
how can I get the full number in a string?
...
Hi, I'm very new to Ada and was trying to see if it offers double precision type. I see that we have float and
Put( Integer'Image( Float'digits ) );
on my machine gives a value of 6, which is not enough for numerical computations.
Does Ada has double and long double types as in C?
Thanks a lot...
...
The sun jdk implementation looks like this:
return v != v;
Can anyone explain how that works?
...
So I'm serializing a C data structure for cross-platform use, and I want to make sure I'm recording my floating point numbers in a cross-platform manner.
I had been planning on just doing
char * pos;
/*...*/
*((double*) pos) = dataStructureInstance->fieldWithOfTypeDouble;
pos += sizeof(double);
But I wasn't sure that the bytes wo...
Hello all,
Coding a matrix multiplication in my program, I get precision errors (inaccurate results for large matrices).
Here's my code. The current object has data stored in a flattened array, row after row. Other matrix B has data stored in a flattened array, column after column (so I can use pointer arithmetic).
protected double[,]...
I have a project in Visual Studio 2008 using the .NET 2.0 framework. When I build the project I get two build errors showing as red crosses, but the project still builds successfully. Even more strangely, the errors are in System.Double.cs. The error is "Floating-point constant is outside the range of type 'double'" and they point to the...
Can you help me clarify the usages of the float primitive in Java?
My understanding is that converting a float value to double and vice-versa can be problematic. I read (rather long time ago and not sure that it's actual true anymore with new JVMs) that float's performance is much worse than double's. And of course floats have less prec...
I have come across a precision issue with double in .NET I thought this only applied to floats but now I see that double is a float.
double test = 278.97 - 90.46;
Debug.WriteLine(test) //188.51000000000005
//correct answer is 188.51
What is the correct way to handle this? Round? Lop off the unneeded decimal places?
...