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

Java - Quickest way to check if a string contains a double value

I am reading from many large text files and I have to check if each snippet of text contains a double value or not. The regex code I am currently using is causing my program to run very slowly because in total I am checking 10 billion strings. I…
M9A
  • 3,168
  • 14
  • 51
  • 79
3
votes
2 answers

can't create an array of doubles

I'm trying to create an array of doubles, and I know I can do it like this, double a[200]; but why can't I create one like this? int b = 200; double a[b]; It does not work. Can anyone help me? UPDATE: int count; count = 0 while…
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
3
votes
4 answers

Generating Random Doubles in Java

I'm a Java noob trying to generate a random double between -10 and 10 inclusive. I know with ints I would do the following: Random r = new Random(); int i = -10 + r.nextInt(21); However, with doubles, this doesn't work: Random r = new Random();…
cvoep28
  • 423
  • 5
  • 9
  • 21
3
votes
1 answer

Can double's overflow to negative values?

Hi I am using the g++ compiler and am experiencing (what I think) is underflow of doubles, is this possible and if so how is the behaviour defined I have uploaded the csv format of the covariance matrix (51x51) here: http://pastebin.com/r0fx1qsx…
Aly
  • 15,865
  • 47
  • 119
  • 191
3
votes
2 answers

In Java, two doubles multiplied together are zero?

So, I'm having a very odd issue here. When I multiply the value user.salary by 1.1, for some reason it becomes 0! The original user.salary variable is fine, I confirmed that it is what it's supposed to be with a System.out.println. import…
Blimeo
  • 295
  • 2
  • 3
  • 10
3
votes
2 answers

EditableGrid datatypes: double

I'm using the editablegrid library to make a table editable so I can later edit and update the database I'm pulling data from. I'm having some issues with the metadata header in the jsp. I've got:
Twinhelix
  • 165
  • 2
  • 14
3
votes
1 answer

Matlab - Undefined Error for Input Arguments of Type Double

I'm trying to write a function that does what conv2(h1,h2,A) & conv2(...'shape') does without using the built-in function. (speed is currently not an issue). as defined here: http://www.mathworks.co.uk/help/matlab/ref/conv2.html These are my…
Reanimation
  • 3,151
  • 10
  • 50
  • 88
3
votes
2 answers

C# magic double value parse

Currently I am working with numbers with high precisions in complex calculations. Some of results and source data should be stored in serialized form. Everything was good till I get magic double value: 0.00000060912702792848. Writing that value to…
Gennadiy
  • 31
  • 1
3
votes
3 answers

R Double For Loop

I have a kind of obvious question about doing a double loop in R and could not find the answer on this website. I am using the following code: mu <- c(0, .2, .5, .8) sco <- matrix(nrow = 50, ncol = 4*10) for (mu in mus) { for (i in 1:10) { …
User33
  • 294
  • 3
  • 10
3
votes
1 answer

representation of numbers in bash and printf of hexadecimal numbers in bash

I want to understand how numbers (doubles) are represented in bash and what happens when I printf numbers in hexadecimal format in bash. According to the IEEE 754 standard double should be represented by 64 bits: 52 bits (13 hex numbers) for a…
user1541776
  • 497
  • 4
  • 14
3
votes
2 answers

min change greedy algorithm in java

Ok so i need to make a program to ask me for an amount of money, then I need it to tell me the least amount of coins to make it. The coins I can use are: dollars, quarters, dimes, nickels, and pennies. For example, When I run the program it's…
Emily Jordan
  • 29
  • 2
  • 3
3
votes
1 answer

Conversion of a string to double C#

I have an interesting problem with a specific conversion. When I try to convert the string "0,3" or "0.3", according to the UICulture, to a Double value, the result is 0,29999999. I have not yet found a solution, in order to receive the result…
Costel
  • 43
  • 4
3
votes
1 answer

PHP modulus operator for doubles

I read here that: Modulus with non integer numbers will give unpredictable results. However, I tried to play a bit with it, and it seems to give pretty predictable results: function mod($a, $b) { echo "$a % $b = " . ($a % $b) .…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
3
votes
1 answer

While converting double 0.10 double.parse() converts to 10.0

I have a simple console application in visual studio for testing some code before going big. But now i have a problem with parsing some string to double. When the users input is a String: 0.10 i want to convert this to a double. So the output should…
Dion Segijn
  • 2,625
  • 4
  • 24
  • 41
3
votes
2 answers

Powershell check types of int and double

I need the user to fill in an integer, but with the code shown beneath, also doubles are allowed. How can I change it to allow only integers? do{ $opgegevenGetal = read-host "Enter an integer" if(![bool]($opgegevenGetal -as [int])){ …
Tomzie
  • 1,338
  • 4
  • 19
  • 25
1 2 3
99
100