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:

7762 questions
2
votes
2 answers

LINQ query, ignoring results with certain decimal points

I need to perform a LINQ query on a large database in C#. One of the columns I need to use in the query is a double. I need to omit results that have more than 4 decimal places in this column. The database can't be changed as other programs need to…
Stuart Thomson
  • 499
  • 5
  • 21
2
votes
4 answers

How can I convert string to double?

I am developing an android app. I need to convert string to double. How can I do it?
user887738
  • 63
  • 1
  • 3
  • 10
2
votes
1 answer

Storing monetary values as Doubles but using BigDecimal to calculate values

Currently some of our Hibernate entities are using Doubles to store monetary amounts, the database stores this value as a numeric(10,2). The calculation of these monetary double amounts are always calculated using BigDecimals and then the entity…
David
  • 657
  • 7
  • 18
2
votes
3 answers

Java doubles adding strangely (and no, it's not for money)

So this is the only relevant section of the code System.out.println("first term of " + firstTerm + " second term of " + secondTerm + " third term of " + finalTermHolder + " should equal " +…
Nathan
  • 41
  • 3
2
votes
11 answers

What's wrong with this division?

I think there's a lot for me to learn about data types. Why this happens double result = ((3/8)*100).ToString(); it gives zero .. should be 37,5 ... :(
Emre
2
votes
1 answer

Jack Shirazi DoubleToString java optimization problem

in Jack Shirazi book "Java Performance Tuning", he presents a way to optimize conversion from double to String. the code of the optimization can be found here: http://onjava.com/onjava/2000/12/15/graphics/DoubleToString.java however, there seem to…
Bastien
  • 1,539
  • 2
  • 10
  • 18
2
votes
1 answer

Scaling big values

I've created simple WPF control to draw charts in my application. Now I need to draw a f(x) = 2^x function on it. All values (from specified range) must be visible on the chart - they should be scaled so that f(x) value for maxX will be on right top…
Marcin Robaszyński
  • 772
  • 1
  • 10
  • 21
2
votes
1 answer

double to int16 (generation or conversion?)

fsamp = 2; deltaf = fsamp/nfft; % FFT resolution Nfreqtimestwo = 128; % Used below Nsines = Nfreqtimestwo/2 - 1; % Number of sine waves fmult = [1:Nsines]; % multiplicative factor freq_fund = fsamp/Nfreqtimestwo; freq_sines = freq_fund.*fmult;…
NickHalden
  • 1,429
  • 2
  • 20
  • 30
2
votes
8 answers

How to write 1+1/2+1/3....+1/4999+1/5000 in java?

How to write 1+1/2+1/3....+1/4999+1/5000 in java? I have tried this but didnt work. public class Harmonic{ public static void main(String[] args){ double sum = 0; for(int i=1; i<=5000; i++){ sum+=1/i; } …
Jeff
  • 21
  • 2
2
votes
4 answers

C++ double precision and rounding off

I have the following problem: double a = 6.005; double b = 5.995; I want to set precision of doubles 2 digits after point, for example double c = a+b;// I would like to get 11.99 not 12.00. How can I do this?
user712644
2
votes
1 answer

Finding floating points in a large string

I have a large string that has a series of floating points in string. A typical string would have Item X $4.50 Description of item \r\n\r\n Item Z $4.75... There is really no rhyme or reason for the text. I have the lowest already and I need to find…
Joe Tyman
  • 1,397
  • 4
  • 27
  • 55
2
votes
2 answers

How to extract fractional part of a double value without rounding in c

When i try to extract the fractional part of a double it seems to be rounding down in C, Is there a way to do it without rounding? double t = 8.2; int ipart = (int)t; long long val = abs((long long)(t*1000000)); long long fpart =…
Scarlet
  • 69
  • 6
2
votes
2 answers

Cannot convert value of type 'Int' to expected argument type 'Double'

So I am following this course called "Code With Chris - 14 Day Beginner Challenge (SwiftUI)" (yes I am a beginner), and after each lesson, there is a challenge, I have almost completed the challenge but I couldn't figure out why it wouldn't work, so…
2
votes
1 answer

On GPU, is it possible to get more flops by combining double and float operations?

If a GPU can do N1 single precision operations per second, and N2 double precision operations per second. Is it possible, by mixing (independent) single and double precision operations to achieve N1+N2 total operations per second, or at least…
nat chouf
  • 697
  • 5
  • 10
2
votes
1 answer

Save double with dot format using StringBuilder

stringBuilder.Append(doubleVariable.ToString()); In my case it will write it as for example 0,15 and I would definitely prefer 0.15. I did not find any direct answer to that, I bet it can be applied somehow to ToString().
user15515307
1 2 3
99
100