J
Jurek
I have 10+ experience in C/C++ - mostly automation and graphics. I have
never written any business apps though. Recently I've been asked to write a
simple report that would calculate sales commission. The report needs to be
generated from within a C/C++ app. I don't want to mess it up so I thought
maybe someone from this group could give me some advice or point to me to a
place that'll provide some background on the issue.
Here is a description of the problem...
A salesperson sales items for a price (p). Each item category has a
commission rate (r) assigned to it. In a simple way I would calculate a
commission (c) as follows:
c = p * r and then round c to 2 decimal places.
The total for the report would be a sum of all commissions (rounded)
calculated for the items.
Is this the way to do that? Some item prices might be really low and I'm
concerned that floating point arithmetic that can get out of hand. Is
rounding to 2 decimal places a 'standard' in such cases?
I'd appreciate any suggestions,
Thanks
Jurek
never written any business apps though. Recently I've been asked to write a
simple report that would calculate sales commission. The report needs to be
generated from within a C/C++ app. I don't want to mess it up so I thought
maybe someone from this group could give me some advice or point to me to a
place that'll provide some background on the issue.
Here is a description of the problem...
A salesperson sales items for a price (p). Each item category has a
commission rate (r) assigned to it. In a simple way I would calculate a
commission (c) as follows:
c = p * r and then round c to 2 decimal places.
The total for the report would be a sum of all commissions (rounded)
calculated for the items.
Is this the way to do that? Some item prices might be really low and I'm
concerned that floating point arithmetic that can get out of hand. Is
rounding to 2 decimal places a 'standard' in such cases?
I'd appreciate any suggestions,
Thanks
Jurek