Questions tagged [rounding]

Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation.

Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation; for example, replacing £23.4476 with £23.45, or the fraction 312/937 with 1/3, or the expression √2 with 1.414.

5484 questions
2
votes
0 answers

Round function does return different value depending on the type

I just found this strange thing digging for an error in my code: import pandas as pd dt=pd.DataFrame(columns=['number']) dt=dt.append({'number':…
2
votes
1 answer

Round double to nearest uint64_t

I need to round a double to the nearest valid uint64_t. So uint64_t…
Bomaz
  • 1,871
  • 1
  • 17
  • 22
2
votes
1 answer

How can I round up decimal values in C++?

If I have, for example, the number 9.83333 and I want to round it to 9.84 or 9.9. How can I do this?
2
votes
1 answer

C#: Math Round() results different values for different decimals

I am getting a different value when using Math.Round with different decimal points, can someone correct me where am I going wrong. double r = Math.Round(1.235, 2,MidpointRounding.AwayFromZero); double t = Math.Round(19.185,…
SoftwareNerd
  • 1,875
  • 8
  • 29
  • 58
2
votes
1 answer

RoundingMode.DOWN for BigDecimal rounding up instead

I am trying to write a program that calculates the square root of an integer (n) with a specified precision (k) provided by user using the newton's method. The program is working fine however I am noticing what I think is a rounding issue. Can…
neaf
  • 67
  • 4
2
votes
1 answer

Round to nearest 5 up C#

After following the below mentioned links: Link1 Link2 Link3 And the list goes on. I don't think I fully grasp the idea of Math.Round. Lets say I have the following values [73.59, 46.28] now I want to road both up to the next 5. After using…
Ruben Redman
  • 489
  • 1
  • 6
  • 21
2
votes
1 answer

Ada 2012 - replace Fixed_Decimal_Type'Round() with customised version?

Recently I have had joyous success when providing my own replacement 'Write () procedure for a custom record type, such as... type Pixel_Format is record -- blah blah end record; procedure Pixel_Format_Write ( …
user5069935
2
votes
1 answer

Possible method to shorten extremely large numbers?

This is the value of the double "m" in my program (the mass of a planet after calculations, this value is specifically for the mass of Earth) 5.973405437304745E24 When printing using System.out.println(m); The output is 5.973405437304745E24…
BipoN
  • 93
  • 8
2
votes
1 answer

R: round up from .6

How rounding up starting at .6 (not at .5)? For example, round(53.51245, 4) will return me 53.5125, but I want 53.5124. How can I specify a separation number (namely increase the values ​​starting from .6)?
red_quark
  • 971
  • 5
  • 20
2
votes
1 answer

How to fix 'Unrecognized expression $round' while applying it to stored data in pipeline using mongodb $and condition with $lookup

I have applied precision to the data coming from DB, while viewing it in browser using Angular 7. Front End: Angular 7 Back End: Java and Mongodb before precision (in db): 100.9999 after precision visible to user(2 after decimal): 101.00 There…
swap_7
  • 23
  • 1
  • 6
2
votes
1 answer

ROUND and WORKSHEETFUNCTION.ROUND

Why are the resulting A1 (0.224) and B1 (0.224000006914139) different? Sub a() Cells(1, 1) = Application.WorksheetFunction.Round(Rnd(-1), 4) Cells(1, 2) = Round(Rnd(-1), 4) Cells(1, 3) = "=a1=b1" Cells(1, 4) = "'0.2240" End Sub And how can one copy…
Junyong Kim
  • 279
  • 1
  • 2
  • 10
2
votes
5 answers

C# Round to list values

I'm trying to round a result value to the next number in a list. If the value is (187) I need to set the result to (240) int[] list = new int[] { 16, 25, 35, 50, 70, 95, 120, 150, 185, 240, 300, 400 }; double max; max = list.Where(x => x <=…
Mohamed Ahmed
  • 113
  • 11
2
votes
1 answer

How to round off seconds to the nearest minute?

I am converting [ss] seconds to mm:ss format. But, I also have to round off the value to the nearest minute. For example, 19:29 -> 19 minutes and 19:32-> 20 minutes I have tried using mround function. But it did not work. =MROUND(19.45,15/60/24)…
2
votes
1 answer

Inconsistencies Rounding Up with Ceiling Function

I have to round a data frame to two decimal places and the 1/100s decimal always needs to round up. However I am seeing some odd behavior with the ceiling function that I'm using. a <- c(268.600, 268.700, 268.500) b <- c(22.410, 653.423,…
2
votes
1 answer

RoundOffTest() seems to round UP and DOWN

void RoundOffTest(double number) { // What value would you pass to RoundOffTest() in order to get this output: // BEFORE number=1.785000 round=178.000000 (round down) // AFTER NUMBER=1.785000 round=179.000000 (round up) // //…
Robin
  • 21
  • 3
1 2 3
99
100