|
Thanks for your quick response.
But one question how to get the final value as a integer rather than string. Any Other Option?
int iResult = 06461; /// Output.
REg,
Sbubbu
|
|
|
|
|
Oh boy.
An integer is a number. Like any number, it can have an infinite number of zeros in front of it. Take your house, or flat number - let us say it is six, and the address is Lemon Street. You live at 6 Lemon street. You also could say "I live at 0000006 Lemon Street, and your letters would still arive - but the postman might think you are a little wierd.
You can happily tell Visual studio:
int i = 000000000006461; or
int i = 6461; or
int i = 0006461; etc., etc. They all mean the same.
A string representation of a number is more like a telephone number: "0123 456789" is a different number to "123 456789" because the exchange will not see it as having an area code, as the leading zero is missing. But, you cannot add two telephone numbers together!
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
This is not mathematics forum.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
we no longer have a math forum, so math goes everywhere.
|
|
|
|
|
Luc Pattyn wrote: math goes is everywhere
FTFY
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
You can't. It's impossible.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Or
string.format("{0:00000}", value);
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
two comments:
1.
spalanivel wrote: Output : 6461 (note 0's missing)
yes, sure. and how many zeroes are missing? 1? one hundred?
2.
you could (I don't say "should") do what you want with strings and characters, i.e. come up with a method that "increments a string". This is how it would go:
a. copy the original string;
b. look for the rightmost digit that you haven't processed yet;
c. add one to it i.e. replace '0' by '1', or '1' by '2', etc
d. if in step c you replaced '9' by '0' then goto b
e. done
with possible refinement: if b fails, prefix a '1'
|
|
|
|
|
Hi
Can anyone tell me how I can download the first 1000 kb and last 1000 kb of a file in C#?
When downloaded, the file should just be deleted.
Have no clue on how to do this.
Thanks in advance
|
|
|
|
|
You can open the file using a stream and read the first and last 1000 Kb of the file. You can store that data in a seperate file.
|
|
|
|
|
I don't need to store the data - actually, the downloaded bytes should just be deleted afterwards.
Thought about doing something like this:
reader.ReadBytes(1000); reader.Position = (file.Length - 1000); reader.ReadBytes(1000);
Would that work? And what is the file is smaller than 1000kb?
|
|
|
|
|
If the stream is seekable, you're pretty close.
I think, if the stream is smaller than 2000 Kb you should read the entire file? Else you would copy duplicate data and (if the file is less than 1000 Kb) cause an exception.
|
|
|
|
|
i added a report viewer control to my project and selected 2 columns from database table..now i want to add my own custom column in report.hw can i do that?
|
|
|
|
|
Hello guys.
I would like to know how to extract the mathematical
expression from a string and compute the result.
Sample: The user will type 5 + 2 - 3 * 4 which will be in a string format.
Then the result will be assigned to a double variable.
Also, the user can include parenthesis in the expression: 5 + (3 / 9)
Thanks a lot.
|
|
|
|
|
In fact you can have a simple to a more complete solution...
Parsing grammar is based on definitions, for instance BNF, ABNF...
In your case, you can write a simple peace of code in order to have your expression parsed.
But if you want to have a more complexe handling use this pointer and check the section 7.2
[^]
Please update us.
|
|
|
|
|
One approach is to put the expression in a binary tree with numbers (or variables) at the leaves and operators at the interior nodes. Replace higher-precedence operators (and parenthesized expressions) with subtrees first.
To evaluate, do a postorder traversal, applying the operator at each interior node to the values obtained from its two subtrees.
When you're done, the result will be in the root node.
|
|
|
|
|
Hmmm... looks like a teacher assigned an RPN assignment yesterday.
See my response here[^].
|
|
|
|
|
I think without explicity declaring the order of precedence of operator execution ... i.e. : is this infix, postfix, RPN ? ... you cannot begin to respond to this question.
There are some math expression "parser" articles around CodeProject; try this one : [^].
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Hello.
I have a DataGridView with 3 Columns and 100000 Rows.
If I select all rows and press "Del" keys from keyboard,
then it takes too long to delete all of them.
Are there anyways to improve the performance ?
Thanks.
|
|
|
|
|
The grid is updating, and repainting. A lot
You can temporarily disable drawing using the SuspendLayout[^] method, and turn it back on using ResumeLayout.
I are Troll
|
|
|
|
|
In fact the suspend layout will not help on this issue.
You must use a virtual mode in order to avoid such redraw issue.
Look at this all is in....
[^]
|
|
|
|
|
Migounette wrote: In fact the suspend layout will not help on this issue.
I had to check to verify that, and it seems that you are right.
+5
I are Troll
|
|
|
|
|
Perhaps setting the datasource to null and deleting the actual data on a background thread would help?
Alternatively, why put 100,000 rows in a datagrid, nobody will scroll through them all, so filter before load?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
i was tring to write some data to the parallel port using inpout32.dll but i keep getting this exception
SEHException was unhandled:
External component has thrown an exception
this is the code i used
class PortAccess
{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
}
public void OUT()
{
PortAccess.Output(888, 1);
}
am i doing something wrong or wat?
|
|
|
|
|
It may be several problems, but it appears to be an issue with the access of the library or the port.
Which OS are you running ?
More over add this to your main app in order to get the information, please update us.
[STAThread]
static void Main(string[] cmdLine)
{
try
{
Application.ThreadException += ApplicationThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
...
}
catch (Exception exception)
{
...
}
finally
{
...
}
}
|
|
|
|