Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
Questionhow to start a messenger project ?? Pin
abdelhameed812-Apr-06 9:59
abdelhameed812-Apr-06 9:59 
AnswerRe: how to start a messenger project ?? Pin
CWIZO2-Apr-06 20:45
CWIZO2-Apr-06 20:45 
Questionmore precision in division by C# is possible? Pin
luca_la2-Apr-06 9:37
luca_la2-Apr-06 9:37 
AnswerRe: more precision in division by C# is possible? Pin
Guffa2-Apr-06 12:22
Guffa2-Apr-06 12:22 
GeneralRe: more precision in division by C# is possible? Pin
luca_la2-Apr-06 14:40
luca_la2-Apr-06 14:40 
AnswerRe: more precision in division by C# is possible? Pin
Guffa2-Apr-06 19:56
Guffa2-Apr-06 19:56 
GeneralRe: more precision in division by C# is possible? Pin
luca_la2-Apr-06 23:21
luca_la2-Apr-06 23:21 
AnswerRe: more precision in division by C# is possible? Pin
Guffa4-Apr-06 2:37
Guffa4-Apr-06 2:37 
luca_la wrote:
If i have to do a cast before using Round(), it's not a solution!


No, you don't have to do that. The Round method takes a double value. It's after you have done the rounding that you have to do the casting. The method returns a double value, you have to cast that into an integer to store it into an integer variable.

luca_la wrote:
And if i'll can use it, i need to know how much the cost of code increase.


The rounding is done using a single FPU instrution, so it's not expensive at all. It's comparable to casting a double to an integer, which also uses a single FPU instruction.

Consider this line of code:

y = Math.Round(x);

And look the disassembly of the generated code (with my comments):

00000051 fld qword ptr [ebp-44h] ; load from x<br />
00000054 frndint ; round<br />
00000056 fstp qword ptr [ebp-58h] ; store in temp<br />
00000059 fld qword ptr [ebp-58h] ; load from temp<br />
0000005c fstp qword ptr [ebp-4Ch] ; store in y


As you see, the rounding itself is just one instruction, and the rest is just getting the data in and out of the FPU stack and storing the result. If you use the method in an expression, the value doesn't even have to leave the FPU stack between operations.


---
b { font-weight: normal; }

GeneralRe: more precision in division by C# is possible? Pin
luca_la7-Apr-06 3:22
luca_la7-Apr-06 3:22 
QuestionGetting an object's bytes Pin
martin_hughes2-Apr-06 4:30
martin_hughes2-Apr-06 4:30 
AnswerRe: Getting an object's bytes Pin
User 66582-Apr-06 4:42
User 66582-Apr-06 4:42 
AnswerRe: Getting an object's bytes Pin
Luis Alonso Ramos2-Apr-06 8:52
Luis Alonso Ramos2-Apr-06 8:52 
QuestionBrowsing to a file in forms Pin
naglbitur2-Apr-06 3:53
naglbitur2-Apr-06 3:53 
AnswerRe: Browsing to a file in forms Pin
User 66582-Apr-06 4:14
User 66582-Apr-06 4:14 
GeneralRe: Browsing to a file in forms Pin
naglbitur2-Apr-06 5:58
naglbitur2-Apr-06 5:58 
QuestionMSVS Designer Error Pin
Kordzik2-Apr-06 1:07
Kordzik2-Apr-06 1:07 
QuestionMS ObjectSpaces Pin
Varun Jain 7862-Apr-06 0:21
Varun Jain 7862-Apr-06 0:21 
QuestionSend more than 1024bytes with sockets? Pin
Erikerikerikerikerassa2-Apr-06 0:16
Erikerikerikerikerassa2-Apr-06 0:16 
AnswerRe: Send more than 1024bytes with sockets? Pin
leppie2-Apr-06 8:08
leppie2-Apr-06 8:08 
GeneralRe: Send more than 1024bytes with sockets? Pin
Erikerikerikerikerassa3-Apr-06 2:14
Erikerikerikerikerassa3-Apr-06 2:14 
QuestionDateTime parse help Pin
eggie51-Apr-06 23:00
eggie51-Apr-06 23:00 
AnswerRe: DateTime parse help Pin
mav.northwind2-Apr-06 0:11
mav.northwind2-Apr-06 0:11 
QuestionProblems updating records with Access DB Pin
James M 19821-Apr-06 22:32
James M 19821-Apr-06 22:32 
GeneralRe: Problems updating records with Access DB Pin
Guffa2-Apr-06 4:33
Guffa2-Apr-06 4:33 
QuestionTELNET Pin
picasso21-Apr-06 22:01
picasso21-Apr-06 22:01 

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.