Most voted "rounding" questions
29 questions
Sort by count of
-
14
votes3
answers30199
viewsHow do I round numbers to the nearest integer?
I have numbers double as double a = 0.4, b = 0.5; How do I round it up?
-
10
votes2
answers390
viewsFloat with PHP precision
I am bringing from the database the sum of the values and as a result it returns me as the example below: 6.3285714285714 I wish he’d stay that way: 6.32 I’ve tried the ceil() and the round(), but…
-
8
votes1
answer1119
viewsRounding of 5 cents
In a PHP system I am developing, I need to update a column of the price table. The price field is in the format float and the administrator informs the percentage of increase. Example: Informs that…
-
6
votes3
answers201
viewsRounding up
I have these values, where contrato.Count = 63 and 63/50 = 1.26. I’d like you to round up 2, I’m doing it this way: decimal arrendondamento = contrato.Count / 50; var valorArredondado =…
-
6
votes3
answers185
viewsWhere to place a function "toFixed()` to round up the value?
I would like to round off the final value of my code with the .toFixed() but I don’t know where to put. Here is the code: <script type="text/javascript"> function conversao(fahreinheit) {…
-
5
votes2
answers345
viewsHow does the rounding of the string format work?
Consider the following code snippet: decimal myValue = 3.045M; Console.WriteLine("Result by Math.Round = " + Math.Round(myValue, 2)); Console.WriteLine("Result by string.Format = " +…
-
4
votes1
answer1818
viewsFloating Point Error
Follows the code of total price that is giving floating point error`: //Pr. Total sgItens.Cells[5,l] := FormatFloat('###,###,###,##0.00',StrToFloat(copy(lTemp, 210, 14))); cont:=…
-
4
votes3
answers7464
viewsRound numbers in C# to decimal 0 or 5
I need to round up numbers in such a way that they only have a decimal value of 0 or 5. For example 1 -> 1 1.1 -> 1.5 1.4 -> 1.5 1.5 -> 1.5 1.6 -> 2 2 -> 2 Someone knows a simple…
-
3
votes1
answer2206
viewsMath.Round method does not round correctly
I’m having trouble with the method Math.Round() in C#, some values that it does not round correctly, I will give some examples: Math.Round(1190.245, 2) 1190.245 he should round to 1190.25 since it…
-
2
votes0
answers65
viewsHow does the truncation of a float or double number occur?
I have the following excerpt: double valor = 1.5; while(valor >= 0) { System.out.println(valor); valor -= 0.15; } Output will be truncated numbers due to 8 byte storage for double, correct? (...)…
-
2
votes0
answers43
viewsHow to round a decimal number to another nearest decimal?
So people are having a hard time creating a discount calculator. For example: I want a number x = 2,27 turn 2.3 and x = 2,24 stay 2.2. How to do this?
-
2
votes1
answer1658
viewsDecimal place - Jquery
Good afternoon! The code below calculates the average, however, depending on the value it is periodically decimated, how to round the values in decimals, for example 0.00 or 00.00? Thank you. HTML:…
-
2
votes1
answer1186
viewsHow do I reset the third decimal place in php?
I need a help, I have following problem, I need to round up the third decimal place, as I do? EX: From 3.49 converts to 3.50 From 3.48 converts to 3.50 From 3.43 converts to 3.50 From 3.42 converts…
-
2
votes1
answer746
viewsRounding in SQL
I need to perform a rounding of a result. Oracle looks like this: SALDO_TONELADA = (A.PESO * 20,0); The value of the column A.PESO is of 24.432 and multiplied by 20 gives 488.640. My goal was to…
-
1
votes1
answer1990
viewsHow to limit decimal place?
printf("%.3f", &resp); I am using the following line, however, when comparing to a number, it requires that you have the same decimal place number as the original, for example: 2.963258741 !=…
-
1
votes1
answer2290
viewsHow to use python round
When I use the python round it converts 1.5 to 2, but with 2.5 it leaves 2. How do I make it round 2.5 to 3 ? Where any number other than the number 2
-
1
votes0
answers55
viewsHow to round float in C without using printf()
I’m not getting round the float to the first two decimal places. I wrote my program like this: float valor; scanf("%f", &valor); printf("valor = %f\n", valor); Once compiled, I typed 573.93 to…
-
1
votes0
answers272
viewsC# - 5 significant numbers with at least 2 decimal places
Guys, someone knows a way that I can transform a number with at least 5 significant digits and added to this factor, it should have at least 2 decimal places. Example: -0,00012 >> -0,00012000…
-
1
votes0
answers453
viewsRound decimals with PHP
I need to round decimal numbers down, except for when the decimal place is 5, for example 1.2 I want to round off to 1 and when the number is 1.5 I want to keep the value. I know only 3 functions of…
-
1
votes0
answers490
viewsDecimal rounding according to ABNT 5891
Good morning! Question: Is there a library, or function, that makes rounding according to ABNT NBR 5891? Problem: I have to implement in Javascript a rounding rule following the standard ABNT NBR…
-
1
votes1
answer303
viewsSum of two floats with 2 decimal places resulting in 4 decimal places in JAVA
I am having a JAVA problem where I want to store calculation results with only 2 decimal places in SQL Server. For that at the end of my calculations I perform: Math.round(valor * 100.0f) / 100.0f;…
-
0
votes2
answers3813
viewsHow to truncate decimal in X decimal places?
I am using the following code, but when sending ex:'10.100' to 2 houses it returns '10.1', but it should be '10.10' public decimal TruncarDecimal(decimal value, int decimalPlaces) { decimal…
-
0
votes1
answer69
viewsRaising numbers financially
I am mounting a basic payroll system in VB.NET, and for example when I do splitting 2500 for 220 the result will be 11,363636363636363636363636363636. There is how I make a rounding for example to…
-
0
votes0
answers255
viewsValues with 3 decimal places entering erroneously
I have a textbox in which I inform a value of an item that must be divided to 10 people registered in the system, but that are divided by proportion, who has more item receives more of the new value…
-
0
votes0
answers26
viewsPHP creates numbers in decimal places
I’m racking my brain here. I move to a variable the value of 130.67. Then subtract any value from it and then subray the rest to leave the variable with value 0 (exact). Then I test if the value is…
-
-1
votes1
answer834
viewsHow to round percentage?
I would need the function below in .asp. I have no notion of language, someone can help? Fiz em Javascript, segue: function limparClasse(classe) { var elementos = document.querySelectorAll('.' +…
-
-1
votes0
answers13
viewsSimple rounding to decimal places
The code below results in a number of 12 decimal places after the comma. <?php echo $count_correct_answers / $count_questoes * 100 ; ?> Can you help me correctly include a code to reduce to 2…
roundingasked 3 years, 3 months ago Luís Carlos 1 -
-3
votes1
answer1220
viewsFloat rounding up in python 3
How do I round up python 3 ? For example, the 4000/18 calculation always results in 223.
-
-4
votes2
answers71
viewsPython rounding list
a = [1.2,2.3,3.4] b = [4.1,5.2,6.3] x = 3.4 y = a.index(x) print (y) y1 = b[y] print (y1) As I would in the code if x were 3. and I wanted to show the nearest value. in the case if x = 3, y would…