Questions tagged [double]

Double is a primitive data type used to store fractional numbers that holds a double-precision floating-point (often 64 bits).

In C and C++ double must be at least as large as float (another floating-point type), but its actual size can vary from system to system as it is implementation-defined. It is typically twice the size of float. Many systems store doubles in binary64, a format described in the IEEE 754 technical standard.

Java has a very strict definition for double, requiring it to be stored in binary64 (which is also called double-precision).

More information:

8301 questions
3
votes
2 answers

string.format(format,doubleValue) , precision lost

I have this double value: var value = 52.30298270000003 and when I convert it to string, it losses its precision: var str = string.Format("{0} some text...", value); Console.WriteLine(str); // output: 52.3029827 The number of precision on my…
amiry jd
  • 27,021
  • 30
  • 116
  • 215
3
votes
0 answers

Declare a pointer to pointer inside C# struct

How to convert this c++ struct into C# equivalent? typedef struct readdirplus_hash_bucket { ifs_rdplusbucket **hash; int hash_size; } ifs_rdplushashbucket; I stuck in double pointer. Thanks in advance.
ulughbekula
  • 371
  • 1
  • 3
  • 12
3
votes
3 answers

Double parseDouble adding extra 0's when adding the numbers

I am running weird situation. I am counting the numbers using Double parseDouble. In some situation i am getting extra 0's for instance instead of 109.1 i am getting ... 109.10000001. I am trying to add string from json. Here is the line of code I…
dhiku
  • 1,818
  • 2
  • 22
  • 38
3
votes
3 answers

How to empty a gridview on Android?

I am developping a launcher with two different profiles : one is the main one the other is secondary. If I go on the play store and then come back with the "back" button, I land on my main profile, but there, the icons of my gridview (displayed…
Zizou
  • 1,891
  • 3
  • 15
  • 16
3
votes
1 answer

How to identify BigDecimal from Double in Java

I'm writing a financial application where i'm getting a value as string and need to check if the value is can be fit into double or BigDecimal without data loss. What will be the best way to identify if the string value should be converted to a…
user2331283
3
votes
2 answers

Is it possible to write out a C# double and read it in Java?

Is it possible to write out the 8-byte representation of a double number in C#, and then read in those 8 bytes in Java as the same double number that was encoded?
Nicholas Hill
  • 306
  • 2
  • 18
3
votes
0 answers

Why does dividing a double by zero throws no exception, while dividing a int does?

When we divide a double by zero it doesn't throw any exception but successfully map to the infinity. But not in the case of int. Despite the fact that both int and double have got an upper limit to the value that they can hold, like max double =…
3
votes
2 answers

PInvoke: Issue with returned array of doubles?

I am using PInvoke to call a C++ function from my C# program. The code looks like this: IntPtr data = Poll(this.vhtHand); double[] arr = new double[NR_FINGERS /* = 5 */ * NR_JOINTS /* = 3*/]; Marshal.Copy(data, arr, 0, arr.Length); With Poll()'s…
Lee White
  • 3,649
  • 8
  • 37
  • 62
3
votes
2 answers

Comparing two "Double" variables with -eq/-ne does not validate if number is creater than 2 digits

Im trying to compare two Double variables in Powershell. When the variable is over 2 digits (not counting precision) the equality test fails unexpectedly. Am I missing something obvious here? Here is the test script output: PS C:\test>…
ProfessionalAmateur
  • 4,447
  • 9
  • 46
  • 63
3
votes
1 answer

Why do I have to use double when reading images in matlab?

I'm taking a matlab programming class, and the instructor told us to always write img = double(imread('file.tif')); rather than img = imread('file.tif'); because omitting the double(...) could "cause errors". I'm confused about why these errors…
Cam
  • 14,930
  • 16
  • 77
  • 128
3
votes
3 answers

String "0.080" to double makes 80.00

I have this problem in c#, I want to convert a string to double. textBoxKostOnderhoud.Text = "0.08"; kost.OnderhoudKost = double.Parse(textBoxKostOnderhoud.Text); This makes 80.00 in my database and I don't know why. Is there any solution for this…
Mankeeey
  • 39
  • 4
3
votes
5 answers

Double Precision when a float value is passed in double

I have on question regarding double precision.When a float value is passed into double then I get some different result. For e.g. float f= 54.23f; double d1 = f; System.out.println(d1); The output is 54.22999954223633. Can someone explain the…
Hitesh
  • 703
  • 1
  • 9
  • 14
3
votes
3 answers

Cast char* to double - as bytes

I have a byte array that represents double: char number[8]; I need to cast this to actual double (which has 8 bytes as well). Based on advice I tried this, but it failed: std::cout<<(*((*double)number))<<" is my number.\n"; Why did it fail and…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
3
votes
7 answers

Trying to create a hash table in java using string as key & double as value

In the following program: import java.util.*; public class HashTableStringdouble { // private Hashtable model = new Hashtable();; private Hashtable model = new Hashtable();;…
MdT
  • 871
  • 3
  • 10
  • 15
3
votes
2 answers

Convert double byte integer to single byte-Javascript

Is possible to convert double byte integer to single byte using java script ?? I need to convert double byte numbers as single byte,when it is entered into a text box.Is there any method available in jQuery or javascript.
Shijin TR
  • 7,516
  • 10
  • 55
  • 122
1 2 3
99
100