tagged [double]

How to convert Decimal to Double in C#?

How to convert Decimal to Double in C#? I want to assign the decimal variable "trans" to the double variable "this.Opacity". When I build the app it gives the following error: > Cannot implicitly conv...

Performing Math operations on decimal datatype in C#?

Performing Math operations on decimal datatype in C#? I was wondering if the above was at all possible. For example: When looking at the overload, it requires a double parameter, so I'm not sure if th...

8 Nov at 13:21

Retain precision with double in Java

Retain precision with double in Java The above code prints: How would I get this to just print (or be able to use it as) 11.4?

28 Oct at 22:54

Escape double quotes in a string

Escape double quotes in a string Double quotes can be escaped like this: But this involves adding character `"` to the string. Is there a C# function or other method to escape double quotes so that no...

25 Jun at 12:30

Round double in two decimal places in C#?

Round double in two decimal places in C#? I want to round up double value in two decimal places in c# how can i do that? after round up ### Related: c# - How do I round a decimal value to 2 decimal pl...

23 May at 10:31

Correct format specifier for double in printf

Correct format specifier for double in printf What is the correct format specifier for `double` in printf? Is it `%f` or is it `%lf`? I believe it's `%f`, but I am not sure. ### Code sample

Convert float to double loses precision but not via ToString

Convert float to double loses precision but not via ToString I have the following code: The results are equivalent to: I'm curious to find out why this is?

Converting a double to an int in C#

Converting a double to an int in C# In our code we have a double that we need to convert to an int. Can anyone explain me why `i1 != i2`? The result that I get is that: `i1 = 9` and `i2 = 8`.

25 May at 12:15

Why double.TryParse("0.0000", out doubleValue) returns false ?

Why double.TryParse("0.0000", out doubleValue) returns false ? I am trying to parse string "0.0000" with `double.TryParse()` but I have no idea why would it return false in this particular example. Wh...

11 Dec at 11:26

How to prevent a double-click using jQuery?

How to prevent a double-click using jQuery? I have a button as such: Within jQuery I am using the following, but it still allows for double-clicks: Any idea on how I can prevent double-click?

2 Oct at 22:27

How do I convert a double into a string in C++?

How do I convert a double into a string in C++? I need to store a double as a string. I know I can use `printf` if I wanted to display it, but I just want to store it in a string variable so that I ca...

11 Dec at 19:41

C# Listbox Item Double Click Event

C# Listbox Item Double Click Event I have a list box with some items. Is there anyway I can attach a double click event to each item? If i was to double click Item 2, a Messagebox saying "Item 2" woul...

Swift double to string

Swift double to string Before I updated xCode 6, I had no problems casting a double to a string but now it gives me an error It gives me the error message "double is not convertible to string". Is the...

26 Nov at 19:1

C# 6 how to format double using interpolated string?

C# 6 how to format double using interpolated string? I have used interpolated strings for messages containing `string` variables like `$"{EmployeeName}, {Department}"`. Now I want to use an interpolat...

18 Dec at 03:51

Round to nearest five

Round to nearest five I need to round a double to nearest five. I can't find a way to do it with the Math.Round function. How can I do this? What I want: and so on.. Is there an easy way to do this?

4 Jan at 07:28

Why do some functions have underscores "__" before and after the function name?

Why do some functions have underscores "__" before and after the function name? This "underscoring" seems to occur a lot, and I was wondering if this was a requirement in the Python language, or merel...

Convert "1.79769313486232E+308" to double without OverflowException?

Convert "1.79769313486232E+308" to double without OverflowException? I have this string "1.79769313486232E+308" and am trying to convert it to a .NET numeric value (double?) but am getting the below e...

20 Apr at 04:43

decimal vs double! - Which one should I use and when?

decimal vs double! - Which one should I use and when? I keep seeing people using doubles in C#. I know I read somewhere that doubles sometimes lose precision. My question is when should a use a double...

14 Mar at 13:18

Can C# store more precise data than doubles?

Can C# store more precise data than doubles? `double` in C# don't hold enough precision for my needs. I am writing a fractal program, and after zooming in a few times I run out of precision. I there a...

29 Mar at 13:23

Convert double into hex in C#

Convert double into hex in C# I have this value: I would like to convert it to HEX and print the HEX to the console. I have already converted a string and int into their respective HEX values, but a d...

31 Jan at 13:34

Split double into two int, one int before decimal point and one after

Split double into two int, one int before decimal point and one after I need to split an double value, into two int value, one before the decimal point and one after. The int after the decimal point s...

6 Nov at 11:23

What exactly does Double mean in java?

What exactly does Double mean in java? I'm extremely new to Java and just wanted to confirm what `Double` is? Is it similar to Float or Int? Any help would be appreciated. I also sometimes see the upp...

24 May at 19:31

C# int- or object-to-double casting error explanation

C# int- or object-to-double casting error explanation The below code fails at the last assignment: If both a and b are `int`, what is the cause of this error?

30 Apr at 18:35

Why 0/0 is NaN but 0/0.00 isn't

Why 0/0 is NaN but 0/0.00 isn't Using `DataTable.Compute`, and have built some cases to test: I have changed my code to handle both. But curious to know what's going on here?

15 Aug at 08:35

C# Double - ToString() formatting with two decimal places but no rounding

C# Double - ToString() formatting with two decimal places but no rounding How do I format a `Double` to a `String` in C# so as to have only two decimal places? If I use `String.Format("{0:0.00}%", myD...

28 Feb at 17:56