Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Should 0.5 round up or down? Pin
Richard MacCutchan30-Jan-24 5:23
mveRichard MacCutchan30-Jan-24 5:23 
GeneralRe: Should 0.5 round up or down? Pin
Gerry Schmitz30-Jan-24 8:09
mveGerry Schmitz30-Jan-24 8:09 
GeneralRe: Should 0.5 round up or down? Pin
Richard MacCutchan30-Jan-24 8:20
mveRichard MacCutchan30-Jan-24 8:20 
GeneralRe: Should 0.5 round up or down? Pin
jschell31-Jan-24 4:51
jschell31-Jan-24 4:51 
GeneralRe: Should 0.5 round up or down? Pin
Richard MacCutchan31-Jan-24 6:43
mveRichard MacCutchan31-Jan-24 6:43 
GeneralRe: Should 0.5 round up or down? Pin
trønderen31-Jan-24 10:43
trønderen31-Jan-24 10:43 
GeneralRe: Should 0.5 round up or down? Pin
Richard Deeming31-Jan-24 22:35
mveRichard Deeming31-Jan-24 22:35 
GeneralRe: Should 0.5 round up or down? Pin
jschell1-Feb-24 6:00
jschell1-Feb-24 6:00 
Richard Deeming wrote:
is if you're stuck with .NET Framework,


You can of course add code to potentially handle other situations.

Probably the most stringent part of this is that the developer should be able to show why they are using a specific rounding and then document it. Probably need to explain it as well. Both for potential audits as well as insuring future maintenance programmers do not 'fix' anything.

I have certainly had to explain this to non-developers before that should have already understood it since they were dealing with financial decisions daily.

This would always be the case when dealing with financial transactions. This can even become a problem when developers decide to store currency amounts in floating point data types. Then even something like addition can be impacted by rounding.

I never experienced a problem with scientific results but when I was programming for that I was not aware of any of the issues. To be fair back then even financial institutions did not seem aware of it. The theory was known but in had not made a transition to practical usage (in many cases.)

Richard Deeming wrote:
If the rules are subject to change, then you either need to recompile,


It probably is going to be more complicated than that. For one time calculations then ok. But one must insure that that business rule will never change.

The case I encountered was where the company was using paper records printed years before. Sometimes those were lost. So they printed (ran a report) again. After the rules had changed. No one in the company was aware of this problem until I pointed it out once I needed to do an update on the report.

As you pointed out this required a dynamic solution which I implemented.
GeneralRe: Should 0.5 round up or down? Pin
Richard MacCutchan31-Jan-24 22:42
mveRichard MacCutchan31-Jan-24 22:42 
GeneralRe: Should 0.5 round up or down? Pin
jschell1-Feb-24 5:42
jschell1-Feb-24 5:42 
GeneralRe: Should 0.5 round up or down? Pin
Richard MacCutchan1-Feb-24 5:55
mveRichard MacCutchan1-Feb-24 5:55 
QuestionQuestion about (char* from string) ,(string from char*) and (char* to char) Pin
Jens Eckervogt19-Jan-24 8:24
Jens Eckervogt19-Jan-24 8:24 
AnswerRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Richard Andrew x6419-Jan-24 12:03
professionalRichard Andrew x6419-Jan-24 12:03 
AnswerRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Dave Kreskowiak19-Jan-24 12:35
mveDave Kreskowiak19-Jan-24 12:35 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Jens Eckervogt19-Jan-24 15:15
Jens Eckervogt19-Jan-24 15:15 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Richard MacCutchan19-Jan-24 22:30
mveRichard MacCutchan19-Jan-24 22:30 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Jens Eckervogt19-Jan-24 23:52
Jens Eckervogt19-Jan-24 23:52 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Richard MacCutchan20-Jan-24 0:18
mveRichard MacCutchan20-Jan-24 0:18 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Jens Eckervogt20-Jan-24 5:31
Jens Eckervogt20-Jan-24 5:31 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Dave Kreskowiak20-Jan-24 4:52
mveDave Kreskowiak20-Jan-24 4:52 
AnswerRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Gerry Schmitz19-Jan-24 16:41
mveGerry Schmitz19-Jan-24 16:41 
AnswerRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
jschell22-Jan-24 5:34
jschell22-Jan-24 5:34 
GeneralRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Jens Eckervogt22-Jan-24 14:17
Jens Eckervogt22-Jan-24 14:17 
SuggestionRe: Question about (char* from string) ,(string from char*) and (char* to char) Pin
Richard Deeming29-Jan-24 3:56
mveRichard Deeming29-Jan-24 3:56 
QuestionHow to customize the default .Net Framework Validation Error Messages Pin
Fokwa Divine11-Jan-24 3:30
Fokwa Divine11-Jan-24 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.