Questions tagged [bankers-rounding]

31 questions
1
vote
2 answers

Powershell Midpoint Rounding

I am building an API and the system that I am using just uses midpoint rounding in PowerShell. I've come to find out that certain numbers still disobey this rule and my research as to why has proven futile. Basically, anything below 5 rounds down,…
1
vote
1 answer

Understanding Bankers Rounding in .NET

As I understand, the default rounding mode in .NET is "Bankers Rounding", which follows these rules: If the digit to round by is less than 5, then round down. If the digit to round by is equal to 5 then round to the nearest even number. if the…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
1
vote
1 answer

Why does DecimalFormat round inconsistently?

import java.text.*; public class TryStuffOut { public static void main(String[] args) { double n=12323233.445; DecimalFormat x = new DecimalFormat("#.##"); System.out.println(x.format(n)); } } why does this round the…
Tony
  • 387
  • 1
  • 2
  • 14
1
vote
3 answers

Python round half up on dataframe question

Good afternoon, I would like to round columns in a dataframe to x number of places using the round half up function to ensure that any .5 values are always rounded up as per conventional rounding rules and to avoid the "bankers rounding" issue. The…
Ajk89
  • 13
  • 5
1
vote
1 answer

Why does Bankers Rounding function in Excel VBA give different results depending on number of decimal places?

I'm trying to use the VBA Round() function in a spreadsheet using this handy code I found elsewhere in this forum: Function BankerRound(rng As Double, sig As Integer) As Double BankerRound = Round(rng, sig) End Function But I'm surprised by…
OutThere
  • 467
  • 2
  • 8
  • 19
1
vote
3 answers

How does the int to float cast work for large numbers?

If we cast an integer to a float it needs to be rounded or truncated when it gets too large to be represented exactly by a floating-point number. Here is a small test program to take a look at this rounding. #include #define…
hko
  • 548
  • 2
  • 19
1
vote
2 answers

c++ half even rounding to x digits

Given a float, I want to round the result to 4 decimal places using half-even rounding, i.e., rounding to the next even number method. For example, when I have the following code snippet: #include #include int main(){ float…
Sleik
  • 341
  • 4
  • 11
1
vote
1 answer

Why float's Rounding use round-to-even?

The csapp says: "Rounding toward even numbers avoids this statistical bias in most real-life situations. It will round upward about 50% of the time and round downward about 50% of the time." And how to Prove it?
1
vote
1 answer

Banker's Rounding in Oracle

Is there any internal function in Oracle to support Banker's rounding, I need to use half to odd Banker's rounding in a select query
Vivek Gupta
  • 2,534
  • 3
  • 15
  • 28
1
vote
1 answer

How is Python's ROUND_HALF_EVEN supposed to handle decimals smaller than 1?

It appears that in every definition I can find of round half to even includes nearest even integer (e.g., Python's decimal documentation), as if ONLY integers are rounded to. However, if I round decimals smaller than 1, it appears to follow the same…
orokusaki
  • 55,146
  • 59
  • 179
  • 257
1
vote
1 answer

Teradata - Removing Banker's Rounding with changing settings

I need to mimic a calculation in excel. We have to get the excact answer. The calculation is rounded at several points. Excel round X.5 up. It looks like Teradata is using banker's rounding (round X.5 to the even #). I cannot change the setting…
0
votes
1 answer

Representing numbers with IEEE754 with Round to Nearest Even

I'm currently learning about IEEE754 standard and rounding, and I have an exercise which is the following: Add -325.875 to 0.546875 in IEEE754, but with 3 bits dedicated to the mantissa instead of 23. I'm having a lot of trouble doing this,…
0
votes
1 answer

Rounding error across all column values in Python

Good afternoon, I have a useful piece of code copied in below that appears to work on my dummy data, alas it doesn't work across all values as it goes down the column data. Code is: import pandas as pd from decimal import * Data['Value'] =…
0
votes
1 answer

Do I get wrong output with BigDecimal ROUND_HALF_EVEN rounding?

I have a problem with rounding of BigDecimal numbers using ROUND_HALF_EVEN as described here. I want to round to 2 decimal places: BigDecimal number1 = new BigDecimal("23.867995"); BigDecimal number2 = new BigDecimal("23.868"); Log.d("tag",…
Pa3k
  • 31
  • 2
0
votes
1 answer

Float data type will not work with bankers rounding -- SQL Server 2008

To provide some background, I am currently working on a project of transitioning an Access database and its code to SQL. In the process I changed Access data types of Double to Float in SQL Server; I did this because these data types are closely…
codingManiac
  • 1,654
  • 4
  • 29
  • 42