Most voted "double" questions
Double is a type of primitive data that represents double precision in floating point format (usually 64 bits). Use this tag for questions that directly involve a double data (such as rounding, converting, formatting etc.), DO NOT USE simply by containing a double in your code.
Learn more…41 questions
Sort by count of
-
46
votes2
answers45560
viewsWhat is the correct way to use the float, double and decimal types?
Since college I can’t understand the real difference between the type DOUBLE and FLOAT, I ended up meeting the guy DECIMAL which also treats real values. About the type DECIMAL, found the following…
characteristic-language float language-independent decimal doubleasked 7 years, 4 months ago Marconi 17,287 -
9
votes1
answer4004
viewsHow to limit reading decimals (scanf) of a double variable?
The exercise asks the readings of the variables double are limited to only one decimal place each of them. I tried to put "%.1lf" in the scanf, as we used in the printf, but it didn’t work. How…
-
9
votes1
answer273
viewsHow do I know that the sum of two double’s will be greater than the limit of one double?
Is there any way to know if a sum between two values in the format double will exceed the variable limit double? Example with integer: 2147483648 + 1. In this case it exceeds the limit of an…
-
9
votes2
answers1126
viewsWhat kind of data (double, float) should I use when representing a temperature?
My question is regarding the use of Double and of Float in Java exercises when having to declare a temperature (Celsius scale). Which one should I use in this case? I declared as Double, but the…
-
5
votes1
answer1820
viewsHow to convert string to double without rounding error?
Because the following command: Convert.ToDouble("199998,99") Results in: 199998.98999999 Already the command: Convert.ToDouble("199998,98") Results in: 199998.98000000001 ?…
-
4
votes1
answer336
viewsError when rounding Bigdecimal
I’m performing a calculation with two methods, only since the attributes are of the type double, I’m using the BigDecimal to perform the operation and after that convert to two decimal places only.…
-
4
votes3
answers1175
viewsUsing Double in the compareTo method
I’m having a doubt. I have several methods of comparison, however, one of the attributes used to make the comparison is double. Then an error occurs: Cannot invoke compareTo(double) on the Primitive…
-
4
votes1
answer61
viewsIs it possible to use the DOUBLE data type on 32-bit systems?
The type of data DOUBLE is a 64-bit floating point, but can be used on 32-bit systems without any problem?
-
3
votes2
answers2391
viewsIn PHP, is there a difference between Double and Float?
In some programming languages, Float and Double, although similar, are not the same. But apparently in PHP there is no difference between these two types. Is there any special reason for this?…
-
3
votes1
answer4847
viewsHow do I put the value of a variable inside a textbox?
Guys I’m having a boring problem. I wanted to put the text I took out of a textbox and put in another that this defined as readonly. I wanted it to work as a label. I tried textchange gave error.…
-
3
votes2
answers102
viewsFunction calculates to a certain extent and to
I have a variable double making an account but it reaches a limit [in my case 1.367879] and does not increase more. The code is running normally, the problem is the result that is not more than…
-
3
votes1
answer59
viewsConvert a Double with more than 13 decimal places to String without losing values
I have in C# the following number in Double: 124.00767638369544. When I simply put valor.toString(), the value goes to: 124.007676383695, IGNORING the 0,00000000000044. The system I’m making needs…
-
3
votes1
answer107
viewsDivisions miscalculating in C
#include <stdio.h> int main() { double A, B; double MEDIA; scanf("%f", &A); scanf("%f", &B); MEDIA = (A + B)/2; printf("MEDIA = %5f", MEDIA); return 0; } In this program I have already…
-
2
votes0
answers82
viewsIncorrect double sum of values!
In a client the sum of 10 lines in a table should total 100. The problem is that the reported values total 100 however when adding, even if fail in the code to avoid garbage coming from the…
-
2
votes1
answer499
viewsHow to print a double with 4 houses after the dot in C#?
static void Main(string[] args) { double area, raio , pi; pi = 3.14159; raio = Convert.ToDouble(Console.ReadLine()); area = pi * Math.Pow(raio,2); Console.WriteLine("A={0}\n",area.ToString("N0")); }…
-
2
votes2
answers98
viewsWarning: format '%f' expectts a matching 'double' argument (en)(en)
My first post here and I would like to know, because when I compile my code it gives an error saying the format %f expecting a double, whereas the f is used to float and the variable I’m putting is…
-
1
votes1
answer6279
viewsConvert String to Double while maintaining content
I need Java to convert a String which has a binary value (Ex: "0111010") for a double. I tested: String teste = "101010101"; double number = Double.parseDouble(teste); System.out.println("The number…
-
1
votes2
answers155
viewsHow not to lose the decimals when doing "longProperty1.divide(longProperty2)"?
What I want to do is very simple, I just don’t know how to "do it right" in Javafx: I have two Longproperty (num1 and num2) and a Doubleproperty (resultado), where this Doubleproperty resultado must…
-
1
votes1
answer102
viewsHow to turn Double into Binario Java
I tried to do the method of turning the result of a calculation like this -> public String converteResultado(String resultado) { return…
-
1
votes1
answer1543
viewsDouble Click Android
I’m developing an app that has a list in a RecyclerView and the idea is that the person chooses one or more products from that list and changes color to show that it is selected, but in case the…
-
1
votes1
answer192
viewsProblem with C code
I have a problem to solve in C which is as follows: Read a double precision number and calculate the minimum amount of 100, 50, 20, 10, 2 and 1 real, 50 cents, 25 cents, 10 cents, 5 cents and 1 cent…
-
0
votes1
answer460
viewsDouble check - Java
I’m not getting this check I’ve tried everything, but always gives me this mistake: java.lang.Numberformatexception: Invalid double: "" If anyone can help, thank you. package com.calculadora; import…
-
0
votes0
answers970
viewsFill double zero left in java
I would like to know how to format a doouble with two boxes to the left of the dot and two to the right of the dot. Example: I have double 1.1 I want it formatted to 01.10; input: 10.1 / 1.05 output…
-
0
votes2
answers4385
viewsHow to set a Textview with a DOUBLE variable?
I’m trying to set the variable txtMedia1 with the value of the variable media1. I did so, but the Android Studio indicates that I have to change txtMedia1 to double or media1 for TextView: package…
-
0
votes0
answers76
viewsDouble type number sum error - VBA/VB
look at the situation: I have a routine that does a sum of Price * Qty and stores in a variable to show the total. The sum is composed of 226 items. From 215 the partial result of the sum would be…
-
0
votes3
answers902
viewsHow to convert text field with mask to double
I have a field in the html text type that has a coin mask. I have to save this value in a field of the kind double in the database, but I’m having trouble converting, where the value that would be…
-
0
votes2
answers704
viewsProblems with the result of a sum between double-type numbers
I want to make the following calculation: 615.6555 + 566 I expected this result: 1181.6555 However, this is me returning this: 1181.6554999999998 How do I solve this problem?…
-
0
votes1
answer1522
viewsChange number of digits after comma depending on the situation
I know I can get a limit of digits after the comma with %.2f for float and %.2lf for double. How can I change this limit depending on the occasion? For example: Get a two-digit limit with float that…
-
0
votes1
answer224
viewsWhy does the variable x of the double type always print the same WRONG value in scientific notation?
In this first example I would like to know why the variable x read in double, when it is formatted by the function "printf()" does not display the value correctly, and every time the value is the…
-
0
votes1
answer373
viewsConvert monetary values "R$" to double type
Hello, I have several CSV files, in which were stored in some columns monetary values in real ex: "R$ 1.986,00". However, I intend to pass all CSV to Sqlite and then analyze the data in Power BI.…
-
0
votes0
answers411
viewsJava Beginner Doubt - Why is the result of the double variable wrong?
I made an algorithm that simulates a bank account, where the client can withdraw and deposit values, worked perfectly when I used variables like int, but when I use double type variables (in order…
-
0
votes0
answers24
viewshow to resolve this error? (The argument type 'double' can’t be Assigned to the Parameter type 'int')
if (result & 1 == 1) { result = ~result; } var result1 = (result >> 1) * 0.00001; lList.add(result1); } while (index < len); the project is in . Dart in flutter error: "The argument…
-
0
votes0
answers337
viewsDouble format with two house
I’m treating a file .csv with a id, value (1,214.45) and I need to format a final sum of these values with only two boxes after the comma. I developed the following code snippet: `DecimalFormat df =…
-
0
votes1
answer143
viewsWhy do these two identical codes, one in C++ and the other in Java, give different results?
I’m trying to solve an issue in the URI Online Judge in Java but I’m afraid of 5% error, and what I’ve studied is being caused by the fact that the accuracy of variables in C++ and Java is…
-
0
votes1
answer78
viewsSQL gets Double with "Comma" tab instead of "Dot"
I am developing an ASP.NET application where I need to take a DOBULE typed by the user and pass to the bank. However there is a divergence of information, the DOUBLE of my bank receives separator…
-
0
votes1
answer92
viewsI need to initialize the variable with the value 0, why?
import java.util.Scanner; public class Main { public static void main(String[] args) { int codigo, quantidade; double preco; Scanner sc = new Scanner(System.in); codigo = sc.nextInt(); quantidade =…
-
-1
votes1
answer57
viewsResult 0.0 - even with Typecast or changing variable types
I have this method in the secondary class to calculate the median of a vector: public class Funcoes { .... public void setMediana(int[] valores) { double med; Arrays.sort(valores); int meio =…
-
-1
votes1
answer29
viewsconvert string to double Elasticsearch
Hello, folks are in need of a help with Elasticsearch. I’m trying to do a script conversion, from a string field, to double, but unfortunately, I’m not getting it. the last script I did was this:…
-
-1
votes1
answer65
viewsdecimal division result
I searched here on the forum and I saw similar questions, but I couldn’t solve the problem. Exercise: "Implement a calculator. The program must ask the user for 3 numbers: 'a', 'b' and 'operation'.…
-
-2
votes2
answers25
viewsC# popular a combo box with variable double
That make a combo box with various height values but my code does not run, the result only adds 1.47: for(double i = 1.47; i <= 2.00; i++) { cbxExemplo.Itens.Add(i); }…
-
-2
votes2
answers164
viewsHow to format a double number to N decimals without rounding?
I have a type value double and I would like to format it so that it gets 3 decimals only, unfurnished. For this, I’m trying to utilize the String.format as follows: float value =…