double

How to get max digits for the decimal part that non-integer numeric data types can support?

An user must enter a number into a mask-edit control. But that number is, depending on the underlying property, one of any .NET numeric type. For instance. If the property is sbyte, the maximum number the user can enter (with any digit, from 0 to 9) is 99 and the minimum is -99 (because sbyte ranges from -128 to 127). That is something ...

How to change symbol for decimal point in double.ToString()?

Hello, I would like to change decimal point to another character in C#. I have a double variable value and when I use the command: Console.WriteLine(value.ToString()); // output is 1,25 I know I can do this: Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-GB"))); // output is 1.25 but I don't like it very mu...

g++ Double Free or corruption...But How??

Hi all, I seem to be having problems with my code and wondered if you guys could help me locate the problem...I have tried using gdb and valgrind, the latter being 'more' useful but still i am unable to fix my bug. Below is my code for my classes (This is my shrunk down version but the main essence of the problem persists): /* Vector....

Simple: How do doubles work in Perl?

I am very confused about how decimal numbers work in perl. I'm having trouble multiplying an int with a double. Here's what I have: sub timeEstimate(){ $number = shift; print "Number: $number\n"; $stuff = sprintf("%d", $number * $number * $number) * .2045; print "stuff: $stuff\n"; $totalDownloads = $stuff + ($number * $number) + $number...

Haskell rigid type?

Possible Duplicate: Return specific type within Haskell This code: class Alpha a where half :: Real f => a -> f instance Alpha Double where half a = a/2.0 produces this error: rigid.hs:6:13: Couldn't match expected type `f' against inferred type `Double' `f' is a rigid type variable bound by th...

In the .NET framework, why are there PointF (float) and no "PointD" (double)?

Can anyone explain why, in the .NET framework, there are PointF structures (using the single-precision float type) and no "PointD" (using the double-precision double type)? Did they establish that such precision would never make sense in the System.Drawing namespace? Is there any other reason? ...

Ints and Doubles doing division

Short version: Why don't I have to coerce 60, and int, into a double, so that I can use division with another double if I DO care about the fractional part? Long version: my boss called me out on a line of code. I tested it and it is working perfectly fine, but he thinks I have a bug waiting to happen. int durationinseconds = 61; // ...

Excel VBA Double Addition Error

I'm having a hard time explaining this one. The following function is being used as a worksheet formula. A value of "empty" simply means that the cell was empty and, therefore, there is no value. Given the values {empty, empty, 0.8, 0.2}, the following function is sometimes returning off the wall values like 5.55111512312578E-17. In ...

Remove extra zeros when converting a double to a string in Objective C

So when I convert a double to a string using something like this: double number = 1.1; text = [[NSString alloc] initWithFormat:@"%f", number]; The variable text ends up printing something like this: 1.100000. I realize that this is because of the way the computer stores the value however I need an easy way to remove those extra zeros ...

std::vector<float> and double* - How safe is this?

Is it safe to do this? double darray[10]; vector<float> fvector; fvector.insert(fvector.begin(), darray, darray + 10); // double to float conversion // now work with fvector VS2008 gives me a warning about the double to float conversion. How do I get rid of this warning? I don't think it makes sense to cast darray to float* as that...

C++ double operator+

Possible Duplicates: Incorrect floating point math? Float compile-time calculation not happening? Strange stuff going on today, I'm about to lose it... #include <iomanip> #include <iostream> using namespace std; int main() { cout << setprecision(14); cout << (1/9+1/9+4/9) << endl; } This code outputs 0 on MSVC 9....

Incorrect results for average distance using Dijkstra (java)

The graph is unweighed, an element of the array of HashSets neighbours[] is a node neighbours[1] is node 1 (they start from 0 mind you) with its unique neighbouring nodes say 2 3 4 5. (so neighbours[5] will contain 1). And I have the following method I did with great deal of help as I dont get the algo much beyond theory. The number it ...

Modulus with doubles in Java

How do you deal with Java's weird behaviour with the modulus operator when using doubles? For example, you would expect the result of 3.9 - (3.9 % 0.1) to be 3.9 (and indeed, Google says I'm not going crazy), but when I run it in Java I get 3.8000000000000003. I understand this is a result of how Java stores and processes doubles, but ...

Wrong value with double.Parse(string)

Hi, I'm trying to convert a string to a double value in .Net 3.5. Quite easy so far with double.Parse(value); My problem is that values with exponential tags are not right converted. Example: double value = double.Parse("8.493151E-2"); The value should be = 0.0893151 right? But it isn't! The value is = 84931.51!!! How can that be...

JTextFields on top of active drawing on JPanel, threading problems.

Dear developers, Has anyone ever tried to use Swing to construct a proper multi-buffered rendering environment on top of which Swing user interface elements can be added? In this case I have an animating red rectangle drawn onto a background. The background does not need to be updated every frame so I render it onto a BufferedImage an...

floor double by decimal place

Hi, i want to floor a double by its decimal place with variable decimal length (in iphone sdk). here some examples to show you what i mean NSLog(@"%f",[self floorMyNumber:34.52462 toPlace:2); // should return 34.52 NSLog(@"%f",[self floorMyNumber:34.52662 toPlace:2); // should return 34.52 NSLog(@"%f",[self floorMyNumber:34.52432 toP...

how do I check if input from cin is a double?

Possible Duplicates: How to validate numeric input C++ how do I validate user input as a double in C++? I need to get input from the command line and check if it is a valid number... storing it as a double. If the input is invalid, I need to keep asking for a number. double x; cout << '>'; cin >> x; while (/*x is invalid*...

how do I validate user input as a double in C++?

How would I check if the input is really a double? double x; while (1) { cout << '>'; if (cin >> x) { // valid number break; } else { // not a valid number cout << "Invalid Input! Please input a numerical value." << endl; } } //do other stuff... The above code infinitely outputs the Inv...

How can I convert a OLE Automation Date value to a date in SQL Server

My application stores dates as OLE Automation doubles with the DateTime.ToOADate() command. Now, I need to create a SQL view wich shows me the Date stored. How can I quickly convert the double to a date? Thanks ...

jqGrid Cell Editing - Double Click to Edit?

By default, if a jqGrid cell is editable, single click on that cell changes it to edit mode. Is there any way I can make it edit on a double click instead? It would make it easier to do row-level operations such as deleting, as all the columns in my grid are editable. ...