Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
AnswerRe: Secure Data Exchange Between WinfForm app and Web Service Pin
Ravi Bhavnani4-Sep-08 4:02
professionalRavi Bhavnani4-Sep-08 4:02 
GeneralRe: Secure Data Exchange Between WinfForm app and Web Service Pin
#realJSOP4-Sep-08 4:11
mve#realJSOP4-Sep-08 4:11 
AnswerRe: Secure Data Exchange Between WinfForm app and Web Service Pin
led mike4-Sep-08 5:29
led mike4-Sep-08 5:29 
AnswerRe: Secure Data Exchange Between WinfForm app and Web Service Pin
leppie4-Sep-08 9:05
leppie4-Sep-08 9:05 
GeneralRe: Secure Data Exchange Between WinfForm app and Web Service Pin
#realJSOP5-Sep-08 0:20
mve#realJSOP5-Sep-08 0:20 
GeneralRe: Secure Data Exchange Between WinfForm app and Web Service Pin
leppie5-Sep-08 3:50
leppie5-Sep-08 3:50 
Questiondouble Pin
RugbyLeague4-Sep-08 2:20
RugbyLeague4-Sep-08 2:20 
AnswerRe: double [modified] Pin
c24234-Sep-08 2:51
c24234-Sep-08 2:51 
I would guess that at least one of these numbers cant be expressed exactly in binary, leading to a loss of precision

A simplified example:
0.3
could be approximated as 1/4 + 1/8 (0.01 + 0.001)
= .25 + 0.125
which is 0.375 i.e. a loss of precision

Obviously the .Net framework will have a more complex floating point mechanism to allow more possible numbers, but hopefully you get my point that some floating point numbers are hard to express in binary without some loss of information.

To solve the problem you could perhaps multiply all your floating point numbers by something, add them together and then divide again later - this sometimes will give a more precise answer

for example:
0.3 + 0.3
Approximated to 0.375 + 0.375 = .75 rather then .6
But:
((0.3 * 10) + (0.3 * 10)) / 10
=
(3 + 3) / 10
= 6 / 10 = .6
Converted into bin: 0.11
(which again is a loss of precision, but less so)

Again as a disclaimer, the maths I am trying to use to explain is over simplified and .Net is more complex then this!

Hopefully that helps,
Chris

[Edit: to elaborate on my point here is some test code I just wrote:
int i = 0;
i += 963;
i += 29;
i += 654;
i += 386;
i += 526;
double x = (double)i / 10000;


However I also tried the example given in the OP, and got the correct answer with no precision loss - different OS or version of .Net perhaps...

]

modified on Thursday, September 4, 2008 9:00 AM

AnswerRe: double Pin
RugbyLeague4-Sep-08 2:52
RugbyLeague4-Sep-08 2:52 
AnswerRe: double Pin
Mbah Dhaim4-Sep-08 2:53
Mbah Dhaim4-Sep-08 2:53 
AnswerRe: double Pin
DaveyM694-Sep-08 3:11
professionalDaveyM694-Sep-08 3:11 
GeneralRe: double [modified] Pin
#realJSOP4-Sep-08 3:27
mve#realJSOP4-Sep-08 3:27 
GeneralRe: double Pin
Dan Neely4-Sep-08 4:32
Dan Neely4-Sep-08 4:32 
QuestionPanel screencapture is black in invisible part of panel Pin
joost.versteegen4-Sep-08 2:05
joost.versteegen4-Sep-08 2:05 
AnswerRe: Panel screencapture is black in invisible part of panel Pin
leppie4-Sep-08 9:02
leppie4-Sep-08 9:02 
GeneralRe: Panel screencapture is black in invisible part of panel Pin
joost.versteegen4-Sep-08 23:11
joost.versteegen4-Sep-08 23:11 
GeneralRe: Panel screencapture is black in invisible part of panel Pin
leppie4-Sep-08 23:47
leppie4-Sep-08 23:47 
GeneralRe: Panel screencapture is black in invisible part of panel Pin
joost.versteegen9-Sep-08 20:27
joost.versteegen9-Sep-08 20:27 
QuestionPlease help with Serial Communication [modified] Pin
introuble24-Sep-08 2:00
introuble24-Sep-08 2:00 
AnswerRe: Please help with Serial Communication Pin
Gideon Engelberth4-Sep-08 3:05
Gideon Engelberth4-Sep-08 3:05 
GeneralRe: Please help with Serial Communication Pin
introuble24-Sep-08 3:32
introuble24-Sep-08 3:32 
GeneralRe: Please help with Serial Communication Pin
Mbah Dhaim4-Sep-08 10:12
Mbah Dhaim4-Sep-08 10:12 
GeneralRe: Please help with Serial Communication Pin
Gideon Engelberth4-Sep-08 12:32
Gideon Engelberth4-Sep-08 12:32 
GeneralRe: Please help with Serial Communication Pin
introuble24-Sep-08 22:23
introuble24-Sep-08 22:23 
GeneralRe: Please help with Serial Communication [modified] Pin
introuble217-Sep-08 22:22
introuble217-Sep-08 22:22 

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.