double

Double Precision

Hi every body! I have a code, and I do not understand it. I am developing an application which precision is very important. but it does not important for .NET, why? I don't know. double value = 3.5; MessageBox.Show((value + 1 * Math.Pow(10, -20)).ToString()); but the message box shows: 3.5 Please help me, Thank you. ...

How to generate double value from TimeSpan

Hi, I have to calculate the relative time which is TimeSpan relativeTime = currentTime.Subtract(startTime); Next I would like to convert relativeTime to double value which should be consisted of seconds and milliseconds (seconds.milliseconds). Does anyone know what is the best way to generate such double value from time difference? ...

Inaccurate division of doubles (Visual C++ 2008)

I have some code to convert a time value returned from QueryPerformanceCounter to a double value in milliseconds, as this is more convenient to count with. The function looks like this: double timeGetExactTime() { LARGE_INTEGER timerPerformanceCounter, timerPerformanceFrequency; QueryPerformanceCounter( if (QueryPerformance...

Convert float to double without losing precision

I have a primitive float and I need as a primitive double. Simply casting the float to double gives me weird extra precision. For example: float temp = 14009.35F; System.out.println(Float.toString(temp)); // Prints 14009.35 System.out.println(Double.toString((double)temp)); // Prints 14009.349609375 However, if instead of casting, I o...

How do I convert a CString to a double in C++?

How do I convert a CString to a double in C++? Unicode support would be nice also. Thanks! ...

Why do some const variables referring to some exported const variables get the value 0?

Consider the following. I have two exported constants as follows: // somefile.h extern const double cMyConstDouble; extern const double cMyConstDouble2; and // somefile.cpp const double cMyConstDouble = 3.14; const double cMyConstDouble2 = 2.5*cMyConstDouble; These constants are now referenced some place else to define two static (...

std::string to float or double

Hello, i'm trying to convert std::string to float/double. I tried: std::string num = "0.6"; double temp = (double)atof(num.c_str()); But it always returns zero. Any another ways? You could see debugger result in this screen: ...

Define a double array without a fixed size ?

Hello i have a problem with c# Arrays. I need a array to store some data in there... My Code is that double[] ATmittelMin; ATmittelMin[zaehlMittel] = Gradient(x, xATmax, y, yATmax); But the compiler says: not defined var How can i define a double array without a fixed size ? Thanks a lot! ...

How do I convert a Python float to a hexadecimal string in python 2.5? Nonworking solution attached.

What I really need to do is to export a floating point number to C with no precision loss. I did this in python: import math import struct x = math.sqrt(2) print struct.unpack('ii', struct.pack('d', x)) # prints (1719614413, 1073127582) And in C I try this: #include <math.h> #include <stdio.h> int main(void) { unsigned long long ...

double type array use in J2ME

I have use Double type array, it works in Emulator but showing error in mobile, what is the problem?? ...

Should I use double or float ?

What are the advantages and disadvantages of using one instead of the other in C++? ...

The Double Byte Size in 32 bit and 64 bit OS

Is there a difference in double size when I run my app on 32 and 64 bit environment? If I am not mistaken the double in 32 bit environment will take up 16 digits after 0, whereas the double in 64 bit will take up 32 bit, am I right? ...

How do I in JDBC read a possibly null double value from resultSet?

I have a column in my database that is typed double and I want to read the value from it using a JDBC ResultSet, but it may be null. What is the best way of doing this? I can think of three options none of which seem very good. Option 1: Bad because exception handling verbose and smelly double d; try { d = rs.getDouble(1); // do ...

Convert double to string C++?

I want to combine a string and a double and g++ is throwing this error: main.cpp: In function ‘int main()’: main.cpp:40: error: invalid operands of types ‘const char [2]’ and ‘double’ to binary ‘operator+’ Here is the line of code which it is throwing the error on: storedCorrect[count] = "("+c1+","+c2+")"; storedCorrect[] is a stri...

Using Xaml and WPF, How do you animate a property on click, and then reverse on successive clicks.

I would like to know if there is a way to use only XAML to perform an animation on a property, and then on the next click perform the reverse animation? Here is a sample of the Trigger I have on a Border object to give the appearance of sliding out: <!-- Animates the Width to Slide It Out. --> <EventTrigger RoutedEvent="Border.MouseLef...

Large numbers rounding off [c#]

I am having some weird issue here. I have a database table which has huge value stored on a column. My application (C#) is reading this value and keeping in a double type. This application will insert the same value to another table. Note : I am not doing any calculations/processing on the value read from the first table. It is just kept...

C/C++ rounding up decimals with a certain precision, efficiently

I'm trying to optimize the following. The code bellow does this : If a = 0.775 and I need precision 2 dp then a => 0.78 Basically, if the last digit is 5, it rounds upwards the next digit, otherwise it doesn't. My problem was that 0.45 doesnt round to 0.5 with 1 decimalpoint, as the value is saved as 0.44999999343.... and setprecisi...

Formatting a double output using BufferedWriter in Java

I'm working on an assignment, and have completed the code, however I am having an issue with correct formatting of the output. I am taking a text file, separating the products based by price, and appending the data to two separate files. How do I make the format of the double correct with the BufferedWriter so that it appears as money ...

Looking for an easier way to use floats in C#

For a number of reasons, I have to use floats in my code instead of doubles. To use a literal in my code, I have to write something like: float f = 0.75F; or the compiler will barf since it treats just "0.75" as a double. Is there anything I can put in my code or set in Visual Studio that will make it treat a literal like "0.75" as ...

Decimal data type in Visual Basic 6.0

I need to do calculations (division or multiplication) with very large numbers. Currently I am using Double and getting the value round off problems. I can do the same calculations accurately on C# using Decimal type. I am looking for a method to do accurate calculations in VB6.0 and I couldn't find a Decimal type in VB6.0. What is the...