English 中文(简体)
货币在人民和少数人之间的微小差距? [闭门]
原标题:Money fractional divide between people and fractions of penny? [closed]
Closed. This question is off-topic. It is not currently accepting answers.

。 因此,在Stack Overflow的

Closed 11 years ago.

我有一笔数额的<代码>9558.99,我需要分四人:40%、40%、10%、10%。

当我计算分数时,我得出以下结果,这些结果都含有笔数的分数,这是不好的,因为显然我只能给一个人一半的笔金。

40%  $3823.5960
40%  $3823.5960
10%  $955.8990
10%  $955.8990
SUM  $9558.99

如果我四舍五入,我就得对:

40%  $3823.60
40%  $3823.60
10%  $955.90
10%  $955.90
SUM  $9559.00 <-- 1 penny over

如果我四舍五入,就会少花3门(而不是pri头):

40%  $3823.59
40%  $3823.59
10%  $955.89
10%  $955.89
SUM  $9558.96 <-- 3 pennies under

因此,我的问题是,根据百分比公平分配数额的正确做法是什么?

EDIT:这可能不是一个方案拟定问题,但我认为这个问题与方案管理员有关。

最佳回答

Round合,随意冲销过度的pen。

随机细分:<代码>n随机人口,n <>/code> = 左侧/penny(s)。

Intuitively speaking I believe that n will not be greater than 3 in this scenario.

(以替代方式,任意 round下和散布剩余的pen)。

问题回答

无论你使用哪一种四舍五入的方法,人们都会失去。

这里的建议

Person A gets 40% of the total - round to nearest penny.
Person B gets 40/60 of what s left - round to nearest penny.
Person C gets 10/20 of what s left - round to nearest penny.
Person D gets what s left.

A gets $3823.60
B gets $3828.59
C gets $955.90
D gets $955.90





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...