double

Different kinds of doubles in vb.net?

Hey all- I'm using QBFC to generate invoices in a Quickbooks integrating app. I'm getting an exception thrown for lineItem.Amount.SetValue(val as Double) when I try to enter a programmatically generated double. The following does not work: lineItem = invoice.ORInvoiceLineAddList.Append.InvoiceLineAdd Dim amount as Double amount = s...

GCC problem with raw double type comparisons

I have the following bit of code, however when compiling it with GCC 4.4 with various optimization flags I get some unexpected results when its run. #include <iostream> int main() { const unsigned int cnt = 10; double lst[cnt] = { 0.0 }; const double v[4] = { 131.313, 737.373, 979.797, 731.137 }; for(unsigned int i = 0; i ...

strtod() and sprintf() inconsistency under GCC and MSVC

I'm working on a cross-platform app for Windows and Mac OS X, and I have a problem with two standard C library functions: strtod() - string-to-double conversion sprintf() - when used for outputting double-precision floating point numbers) Their GCC and MSVC versions return different results, in some digits of mantissa. But it plays a...

Reducing decimal places in Delphi

I am storing a list of numbers (as Double) in a text file, then reading them out again. When I read them out of the text file however, the numbers are placed into the text box as 1.59993499 for example, instead of 1.6. AssignFile(Pipe, 'EconomicData.data'); Reset(Pipe); For i := 1 to 15 Do ReadLn(Pipe, SavedValue[i]); Close...

Printing double variable contents

I tried following code snippet and output is surprising me: #include <stdio.h> #include <math.h> int main() { double num; unsigned char ch; ch = 19; num = 1.0E+20 ; num += ch * 1.0E+18; printf("E18 = %lf \n",num); printf("E18 = %e \n",num); ...

Convert Delphi Real48 to C# double

Hey, I need to be able to convert from a Delphi Real48 to C# double. I've got the bytes I need to convert but am looking for an elegant solution. to the problem. Anybody out there had to do this before? I'm needing to do the conversion in C# Thanks in advance ...

Unsigned double in C++?

Hello everyone, Why doesn't C++ support unsigned double syntax? Thanks in advance ...

double to hex. How It's Made?

157,453796 = hex 18068A 157,455093 = hex 180697 71,5037 = hex E91D00 71,506104 = hex E93500 71,507103 = hex E93F00 0 = hex 000000 I know exactly what it is not IEEE 754 ...

C# newbie problem with variable types

int newWidth = 100; int newHeight = 100; double ratio = 0; if (img1.Width > img1.Height) { ratio = img1.Width / img1.Height; newHeight = (int)(newHeight / ratio); } else { ratio = img1.Height / img1.Width; newWidth = (int)(newWidth / ratio); } Image bmp1 = img1.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero); ...

c++ floating point precision loss: 3015/0.00025298219406977296

The problem. Microsoft Visual C++ 2005 compiler, 32bit windows xp sp3, amd 64 x2 cpu. Code: double a = 3015.0; double b = 0.00025298219406977296; //*((unsigned __int64*)(&a)) == 0x40a78e0000000000 //*((unsigned __int64*)(&b)) == 0x3f30945640000000 double f = a/b;//3015/0.00025298219406977296; the result of calculation (i.e. "f"...

Octave datatypes - float & double

I'm writing a framework for writing HDF files with JAVA (Using some existing framework). I need to keep compatibility with octave. That is, octave should be able to read the files my framework writes and vice versa. My question is, does Octave have two data types - float and double or it uses only double? thanks ...

Convert C# double to Delphi Real48

Hi, I've found the following question Convert Delphi Real48 to C# double but I want to go the other way, C# to Delphi. Does anyone know how this can be done? I've tried reverse engineering the code but without much luck. Update: I'm after C# code that will take a double and convert it into a Real48 (byte[] of size 6). Thanks ...

bash: expanding variables with spaces

I have a file called "physics 1b.sh". In bash, if i try x="physics 1b" grep "string" "$x".sh grep complains: grep: physics 1b: No such file or directory. However, when I do grep "string" physics\ 1b.sh It works fine. So I guess the problem is something to do with the variable not being expanded to include the backslash that gr...

Binary files printing and desired precision

Hi, I'm printing a variable say z1 which is a 1-D array containing floating point numbers to a text file so that I can import into Matlab or GNUPlot for plotting. I've heard that binary files (.dat) are smaller than .txt files. The definition that I currently use for printing to a .txt file is: void create_out_file(const char *file_nam...

Find max integer size that a floating point type can handle without loss of precision

Double has range more than a 64-bit integer, but its precision is less dues to its representation (since double is 64-bit as well, it can't fit more actual values). So, when representing larger integers, you start to lose precision in the integer part. #include <boost/cstdint.hpp> #include <limits> template<typename T, typename TFloat>...

Java image with double value pixel

Actually I'm working with BufferedImages, that provide me pixel values in int type. Do you know a Java object to represent an image that the pixel value in double or float type? ...

Java Swing jtable cell editor doubles E numbers

Hi I an issue with editors in a JTable. I have a column which displays data as 26,687,489,800.00 ie: Double. When the user clicks the cell to edit the data it is displayed as -2.66874908E10. I want the data to be edited as it appears when it is displayed ie: 26,687,489,800.00 - without the E10 etc... Any help would be appreciated. M...

Forcing positive sign on double in .Net String.Format

Context: .Net, C# I want to print a complex number made from two doubles. The sign needs to show on the imaginary part. I'd like to use the default double formatting for each part to minimize the number of characters. I tried using String.Format("{0:+G;-G}{1:+G;-G}j", real, imaginary) but this ended up printing: "+G-Gj". Not quit...

erroneous Visual C float / double conversion?

In Visual C++ i wrote the following sample in a C++ program: float f1 = 42.48f; double d1 = 42.48; double d2 = f1; I compiled the program with Visual Studio 2005. In the debugger i see the following values: f1 42.480000 float d1 42.479999999999997 double d2 42.479999542236328 double d1 by my knowledege is OK, but d2 is wron...

Quick C question - how to hide leading zero in printf

Hey, if I had this code: printf( "%8.2f" , .23 ); It outputs 0.23. How do I get it to simply output .23? Thanks. ...