Click here to Skip to main content
15,920,633 members
Home / Discussions / C#
   

C#

 
QuestionSetting return code in console app? Pin
LongRange.Shooter29-Oct-04 10:15
LongRange.Shooter29-Oct-04 10:15 
AnswerRe: Setting return code in console app? Pin
Heath Stewart30-Oct-04 3:30
protectorHeath Stewart30-Oct-04 3:30 
GeneralRe: Setting return code in console app? Pin
LongRange.Shooter1-Nov-04 2:23
LongRange.Shooter1-Nov-04 2:23 
Generalmemcopy in C# Pin
youssef29-Oct-04 10:07
youssef29-Oct-04 10:07 
GeneralRe: memcopy in C# Pin
Ami Bar29-Oct-04 11:51
Ami Bar29-Oct-04 11:51 
GeneralRe: memcopy in C# Pin
Heath Stewart30-Oct-04 3:27
protectorHeath Stewart30-Oct-04 3:27 
QuestionBest way to validate dates? Pin
house29-Oct-04 9:35
house29-Oct-04 9:35 
AnswerRe: Best way to validate dates? Pin
Luis Alonso Ramos29-Oct-04 9:39
Luis Alonso Ramos29-Oct-04 9:39 
GeneralRe: Best way to validate dates? Pin
house1-Nov-04 2:55
house1-Nov-04 2:55 
GeneralRe: Best way to validate dates? Pin
Luis Alonso Ramos1-Nov-04 5:31
Luis Alonso Ramos1-Nov-04 5:31 
AnswerRe: Best way to validate dates? Pin
Nick Parker29-Oct-04 14:20
protectorNick Parker29-Oct-04 14:20 
QuestionHow to initially set the focus to a control Pin
Luis Alonso Ramos29-Oct-04 9:28
Luis Alonso Ramos29-Oct-04 9:28 
AnswerRe: How to initially set the focus to a control Pin
Luis Alonso Ramos29-Oct-04 9:44
Luis Alonso Ramos29-Oct-04 9:44 
GeneralC# Double arithmetic producing unstable answers Pin
ldself29-Oct-04 7:46
ldself29-Oct-04 7:46 
GeneralRe: C# Double arithmetic producing unstable answers Pin
Nick Parker29-Oct-04 8:15
protectorNick Parker29-Oct-04 8:15 
GeneralRe: C# Double arithmetic producing unstable answers Pin
Hugo Migneron29-Oct-04 8:17
Hugo Migneron29-Oct-04 8:17 
Hi there,
The reason why 0.3/0.2 does not give an exact result is the following :
C# (and every other compiler) represents your variables in binary values.
For example:
2 is represented by 10 in binary which stands for (1*2^1 + 0*2^0)
4 100 (1*2^2 + 0*2^1 + 0*2^0)
30 11110 (1*2^4 + 1*2^3 + 1*2^2 + 1*2^1 + 0*2^0)
and so on
for values like 0.3, the binary value is not exact, because it is impossible to represent it exactly with this notation...
0.3 is 0,01001100110011... but the number never ends.
Since a double value is represented with 64 0 and 1, you loose a little precision in your operations. There is no real way to avoid this unfortunatly.

I hope this helps
GeneralRe: C# Double arithmetic producing unstable answers Pin
Nick Parker29-Oct-04 15:08
protectorNick Parker29-Oct-04 15:08 
Generalstructs and 'using' Pin
Nemanja Trifunovic29-Oct-04 6:47
Nemanja Trifunovic29-Oct-04 6:47 
GeneralRe: structs and 'using' Pin
leppie29-Oct-04 9:02
leppie29-Oct-04 9:02 
GeneralRe: structs and 'using' Pin
Nemanja Trifunovic29-Oct-04 9:14
Nemanja Trifunovic29-Oct-04 9:14 
GeneralRe: structs and 'using' Pin
Ketty Avashia29-Oct-04 9:27
Ketty Avashia29-Oct-04 9:27 
GeneralRe: structs and 'using' Pin
Nemanja Trifunovic29-Oct-04 9:42
Nemanja Trifunovic29-Oct-04 9:42 
GeneralI got an answer on a C# newsgroup Pin
Nemanja Trifunovic29-Oct-04 10:00
Nemanja Trifunovic29-Oct-04 10:00 
GeneralRe: structs and 'using' Pin
Ami Bar29-Oct-04 12:16
Ami Bar29-Oct-04 12:16 
GeneralRe: structs and 'using' Pin
Nemanja Trifunovic29-Oct-04 12:27
Nemanja Trifunovic29-Oct-04 12:27 

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.