|
It running now...
What is the logic Behind that...?
Regards
Pankaj Joshi
|
|
|
|
|
The two operands of the division are both integers hence an integer division is performed, giving 0 as result (the latter is then converted to decimal type, but you've already lost your decimal digits ). By appending an m you force the compiler to interpeter the operand as a decimal and hence to perform a division between decimals yelding the correct result.
BTW the same chan be obtained explicitely casting one of the operands to decimal type, e.g.:
decimal val= (decimal)objNew.Length / 1048576;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
pankaj.indore wrote: decimal val=objNew.Length / 1048576;
AS the number on the right hand side of the operator is an int, it will return an int. Replace 1048576 with 1048576.00
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thx Sir,
its running now...
But what is the actual problem i can't get yet...?
i don't think their is a difference between 1048576.00 and 1048576
please clear it to me.
Regards
Pankaj Joshi
|
|
|
|
|
1048576 is a literal of the type int .
1048576.0 is a literal of the type double .
When you do a division where both operands are int , the result is an int .
When you do a division where one or both of the operands are double , the result is a double .
1048576m is a literal of type Decimal . I would suggest that you avoid the Decimal data type, unless you actually need it's higher precision. (Which you don't do in this case.)
---
single minded; short sighted; long gone;
|
|
|
|
|
Thx For your Reply,
I got the actual problem but still have a doubt see code below
Dim d as double
d=5/3
messagebox.show(k.tostring())
result 1.666666667
but in C# it give 1 whyyyyyyyyyyyyyyyy
I know your answer is int/int result int . but my dear friend type casting proves maths wrong...?
universe know this 5/3 = 1.666666....
why C# dosen't...?
Regards
Pankaj Joshi
|
|
|
|
|
pankaj.indore wrote: I know your answer is int/int result int . but my dear friend type casting proves maths wrong...?
universe know this 5/3 = 1.666666....
why C# dosen't...?
I don't remember much VB, but I think equivalent to 5/3 in C# is 5 div 3 in VB. Do you know the difference now?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
pankaj.indore wrote: Dim d as double
d=5/3
messagebox.show(k.tostring())
result 1.666666667
but in C# it give 1 whyyyyyyyyyyyyyyyy
Christian already explained it to you.
5 and 3 are both integers. If you do integer division your result will be an integer.
1.667 is not an integer.
pankaj.indore wrote: universe know this 5/3 = 1.666666....
Only when it is doing floating point division. When it is doing integer division the result is 1.
Obviously VB performs floating point division, while C# uses integer division (unless told not to, by having the values cast before).
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
This VB code:
d = 5 / 3
is equivalent to this C# code:
d = (double)5 / (double)3;
The / operator in VB always does floating point division, converting the operands if needed.
---
single minded; short sighted; long gone;
|
|
|
|
|
actually i m new to dot net
i m using oledb connection
and my query is
"select * from tableabc where name = ? and id = ?"
i dont know how to map these parameters to my command object can any body tell me please
thanks
hello
|
|
|
|
|
Before posting your questions here in the forum did you read the guidlines of how to post the question in the forum.
pls make your subject with suitable topic relevant to your question.
Don't name your subject as hi, hi all.
pls be specific in your subject and post the questions here.
Regards,
Satips.
|
|
|
|
|
Create OleDbParameter objects. Assign them a data type and a value and add them to the collection of parameters of the command object IN THE EXACT ORDER THEY APPEAR IN THE STATEMENT.
|
|
|
|
|
In OleDb you use named parameters:
"select * from tableabc where name = @Name and id = @Id"
Use "@Name" and "@Id" as names when you create the parameter objects for the command.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi.
Is there a way to get the number of the print jobs pending for a specified installed printer?
Thanks.
|
|
|
|
|
|
Martin# wrote: Hope it helps!
It sure helped. Thanks a lot!
|
|
|
|
|
hi all
i am passing two parameters via responce.redirect but its not working can
any body please tell me the exzact syntax
Response.Redirect ("Employee.aspx?id= "+ this.DropDownList1.SelectedValue + "?name=" + this.TextBox1.Text);
hello
|
|
|
|
|
ghumman63 wrote: onse.Redirect ("Employee.aspx?id= "+ this.DropDownList1.SelectedValue + "?name=" + this.TextBox1.Text);
Response.Redirect ("Employee.aspx?id= "+ this.DropDownList1.SelectedValue + "&name=" + this.TextBox1.Text);
Regards,
Satips.
|
|
|
|
|
ghumman63 wrote: Response.Redirect ("Employee.aspx?id= "+ this.DropDownList1.SelectedValue + "?name=" + this.TextBox1.Text);
Use an ampersand (& ) symbol to append the fields after the first one as follows:
Response.Redirect ("Employee.aspx?id= "+ this.DropDownList1.SelectedValue + "&name=" + this.TextBox1.Text);
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Thats what i too have mentioned it.
Regards,
Satips.
|
|
|
|
|
Dear Satips,
See the time delay between you and me.
This shows that we are in the same wavelength.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
yeah i didn't notice the time. Ok.
Regards,
Satips.
|
|
|
|
|
Hello everyone,
I'm starting to work on a project. This project will incorporate so many components from previous work of another colleague. He did all his work in a separate project. Basically,I'm trying to
do a wizard-based version of hsi work with screens and neat menus and so on. I was wondering how I can use functions and events that he programmed into my project without having to hard-code or copy code into my own project.
For example, I want to call an event function from his work when i click a "next" button in my project.
I hope the questions is clear enough. and Thanks for any help. It will be much appreciated.
|
|
|
|
|
Recompile his code as a dll/dlls.
Now include reference those dlls in your code.
You might have to make some minor changes to compile it as a dll. (All this on the assumption that his code is currently compiled to an executable, you have good understanding of his code)
rAm
i Think, i Wait, i Fast -- Siddartha
|
|
|
|
|
Hi guys, whats up ? How can I change the Input Language From English to Farsi Or other languages, a friend told me to use this code (This is a delphi ample)
LoadKeyboardLayout('0000040c', KLF_ACTIVATE);<br />
Application.BiDiKeyboard := '0000040c';
Does the same code works in C#, if so where can I get a sample? Please help me out !
Thanx
Mr.K
|
|
|
|