double

Converting a string into a double

I am trying to convert a string (const char* argv[]) to a double precision floating point number: int main(const int argc, const char *argv[]) { int i; double numbers[argc - 1]; for(i = 1; i < argc; i += 1) { /* -- Convert each argv into a double and put it in `number` */ } /* ... */ return 0; } Can any...

C# Double.ToString()

Possible Duplicate: Custom numeric format string to always display the sign To format a double to certain precision in C# I write this: d.ToString("#0.00"); What if I want to force a the sign to appear.. e.g +2.54 and -2.54 ...

C++ double division by 0.0 versus DBL_MIN

When finding the inverse square root of a double, is it better to clamp invalid non-positive inputs at 0.0 or MIN_DBL? (In my example below double b may end up being negative due to floating point rounding errors and because the laws of physics are slightly slightly fudged in the game.) Both division by 0.0 and MIN_DBL produce the same...

How can I convert a byte array into a double and back?

For converting a byte array to a double I found this: //convert 8 byte array to double int start=0;//??? int i = 0; int len = 8; int cnt = 0; byte[] tmp = new byte[len]; for (i = start; i < (start + len); i++) { tmp[cnt] = arr[i]; //System.out.println(java.lang.Byte.toString(arr[i]) + " " + i); cn...

fixing IE7 float inside float bug

hi, in ie7 if you put a floated element inside a floated element to the same side the inside element just pushed far away outside the container element to the direction of the float. consider this code <div style="float: right"> <div style="float: right"> some text </div></div> any solution for this bug?? ...

How to read in a negative double with scanf() in C?

I'm learning basics of C and writing a simple first order equation solver. I want the input to be exactly ax+b=c or ax-b=c, where a, b, c are double type. I'm employing scanf() to read in user input and to check if it's of the correct form. However, if I enter a negative double, -4.6 say, as the "a" in the equation, scanf() won't read t...

Java: Check if two double values match on specific no of decimal places

Comparing those two values shall result in a "true": 53.9173333333333 53.9173 Thanks in advance! ...

asp.net mvc2 validate type double

[MetadataType(typeof(Deal_Validation))] public partial class Deal { } public class Deal_Validation { [Required] public string Title { get; set; } public double? EstValue { set; get; } } How to validate EstValue (check if it is of type double?) Thanks ...

is memset(ary,0,length) a portable way of inputting zero in double array

Possible Duplicate: What is faster/prefered memset or for loop to zero out an array of doubles The following code uses memset to set all the bits to zero int length = 5; double *array = (double *) malloc(sizeof(double)*length); memset(array,0,sizeof(double)*length); for(int i=0;i<length;i++) if(array[i]!=0.0) fprintf(st...

How do you set a double value to a "non-value"

I have two double data elements in an object. Sometimes they are set with a proper value and sometimes not. When the form field from which they values are received is not filled I want to set them to some value that tells me, during the rest of the code that the form fields were left empty. I can't set the values to null as that gives...

Java string to double conversion.

Hi, I've been reading up on the net about the issues with handling float and double types in java. Unfortunately, the image is still not clear. Hence, i'm asking here direct. :( My MySQL table has various DECIMAL(m,d) columns. The m may range from 5 to 30. d stays a constant at 2. Question 1. What equivalent data-type should i be usi...

Reading a Windows 'binary' float into a ASP jscript variable

I need to read files produced by a legacy Windows app that stores real numbers (the 8-byte "double" type) in binary - i.e. as a packed array of 8 bytes. I can read the 8 byte group OK but how can I present it to my ASP JScript code such I can get the real number back again. Or to put it another way: Say a file was produced by a Window...

Is there a 128 or 256 bit double class in .net?

I have an application that I want to be able to use large numbers and very precise numbers. For this, I needed a precision interpretation and IntX only works for integers. Is there a class in .net framework or even third party(preferably free) that would do this? Is there another way to do this? ...

Symfony 1.4 setter type double precision

Hi volks, I want to save a number with 14 decimal places, but symfony only saves 6. How can I control this: $loc->setSinRadLon(0.73946213661883); In the schema the column looks like: sin_rad_lon: { type: double(), scale: 14, notnull: true } The DB stetting is: sin_rad_lon double(18,14) In the DB the column value is: 0.73946...

How many double numbers are there between 0.0 and 1.0?

This is something that's been on my mind for years, but I never took the time to ask before. Many (pseudo) random number generators generate a random number between 0.0 and 1.0. Mathematically there are infinite numbers in this range, but double is a floating point number, and therefore has a finite precision. So the questions are: J...

Function for flipping the sign of a number

How can I change the sign of a number? abs(); will not return me a negative when the input is positive, correct? I need the opposite sign. ...

Are there any common gotchas with using decimal as opposed to double in MySQL?

A friend of mine said that they experienced oddities with using the decimal column to store money formats such as saving 1000.00 which would result in it being stored as 999.99. However I just tested and 1000.00 is stored as 1000.0000 on decimal(19,4) / MySQL 5. Can anyone offer insight into why they may have experienced issues? Perhaps...

storing double values in SQLite: how to ensure precision?

hi there! i have a problem with double values i need to store in an android homed sqlite database. since these double values represent gps values (lat & lng), i really NEED an absolute precision down to the 9th number after the comma. now i have a table like this: CREATE TABLE x REAL lng; and insert sth (hardcoded) like: INSERT INT...

How to get around some rounding errors?

I have a method that deals with some geographic coordinates in .NET, and I have a struct that stores a coordinate pair such that if 256 is passed in for one of the coordinates, it becomes 0. However, in one particular instance a value of approximately 255.99999998 is calculated, and thus stored in the struct. When it's printed in ToStrin...

Java page flipping not supported on Mac OS?

Dear developers, I'm hoping someone happens to have stumbled upon the following issue before. My Java application has graphics performance issues on Mac, so I made a simple test application (code below). When I run this on Windows, the console tells me: GraphicsConfiguration flipping? true BufferStrategy flipping? true When I r...