|
Thanks! I was not aware of the problem with pow(). is there any similar integer issue/fix with Math.Abs() and Math.sqrt() as well?
|
|
|
|
|
invictus3 wrote: s there any similar integer issue/fix with...
each time you convert to and from reals for no good reason you may loose performance, and
may get wrong results due to limited accuracy and/or rounding errors.
x=iabs(x) ==> if (x<0) x=-x;
x=isqrt(x) ==> no simple int solution, but one seldom needs isqrt
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I am grateful for the help.
I got one final question though. Its more relating to the last topic, Math.pow(). I would run Math.pow(94, x), but since you told me that pow was inefficient for integer operations I wonder what is the better way to solve this?
|
|
|
|
|
for loop
while loop
loop + array
94?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Use unsafe code, get the pointer to the string data and then cast it into byte or int or whatever size you want. Then use the binary operator & to do the comparison.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
This was an interesting idea.
Lets assume I have a string that consists only of the ascii symbols from code 32 and up to 126. Now each character must be at least 7 bits long (but probably are 8 as a result of byte of 8 bits). This leads to alot of possible combinations to be checked with the & operator if I want to check for all possible 2-bit patterns (even the one overlapping into the next character).
If I make the assumption that characters are 8 bits and include the first 0 in my calculations (to make it easier) I would still have to test against all possible combinations of 00, 01, 10, and 11 at all two consecutive slots within each character. Furthermore, I would have to test each of the four against the last bit of the current char and the first bit of the next char.
I am fully aware that this post perhaps should be located in the math/algo forum now. The question I now want to ask is this: is there any clever boolean algebra method for testing for this bit pattern in each possible location or do I have to manually test each of the possible locations?
If any mod reads this then perhaps this and the previous posts can be moved to the correct forum. Thank you.
|
|
|
|
|
I don't have the exact method but the strlen method in C in the assembly uses some really good math in a similar method.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
|
Hello...
I have 1 Form and 2 Panels in it. How to catch mousemove event from all of them ?
Now I'm using :
form.MouseMove += new MouseEventHandler(OnMouseMove);
panel1.MouseMove += new MouseEventHandler(OnMouseMove);
panel2.MouseMove += new MouseEventHandler(OnMouseMove);
If there are only 3 control, it's ok, but if I have 20 controls, it will be a little bit complex to write event for all of them.
Thx...
|
|
|
|
|
Use only one event for all the controls.
|
|
|
|
|
Hello experts,
I create an application using C#.net 2005, MS Access 2000. In that application I have one exe and 9-10 DLL's and some xml files are also included. I distribute this application using standard VS.NET setup and deployment project. Everything is working fine.
Now that was release 1.0. After using v1.0 my clients reports some bugs and I also add some more functionality into the application.
If any of my customer needs upgraded version of application then what should I do...? Because I have to change the EXE and DLL's including new and modified xml's. And their may be some database changes are also occurred...please help.
I don't want to use the ClickOnce deployment .. Please guide me......
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Pankaj - Joshi wrote: I don't want to use the ClickOnce deployment .. Please guide me......
First Wake Up, it's difficult to read while sleeping. There are all sorts of installer systems available including of course Windows Installer. I imagine they all support upgrading scenarios. You will just have to do some searching and some reading to figure out which one(s) you want to investigate.
|
|
|
|
|
That means you cant' help me...?
I search a lot but unable to get proper solution...
Please help....
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Pankaj - Joshi wrote: That means you cant' help me...?
You asked for guidance
Pankaj - Joshi wrote: Please guide me
I guided you
Pankaj - Joshi wrote: Please help
If you want more specific help you need to ask more specific questions. I have given you all the general guidance I can on the subject of updating applications. I can't alter the reality that it is a large subject and in many cases it is also somewhat complex. If you desire to be a competent software developer, at some point you have to stop looking for the magic bullet solution to problems and realize you just have to start researching a subject and stick with it until you have gained an understanding of the domain sufficient to provide yourself with a solution to your problem.
led mike
|
|
|
|
|
Hi,
I want to assign Styles to certain WPF UserControls at runtime. The first assignment always works, but assigning other Styles to the control never results in calling the PropertyChangeCallbacks. On the other hand OnStyleChange is called...?
The DP-definition of the UserControl looks like following:
public static readonly DependencyProperty FooterGradientBottomProperty =
DependencyProperty.Register ("FooterGradientBottom", typeof (Color),
typeof (subItem), new FrameworkPropertyMetadata (Color.FromArgb (255, 255, 255, 255),
FrameworkPropertyMetadataOptions.AffectsRender,
new PropertyChangedCallback (FooterGradientBottom_Changed)));
public Color FooterGradientBottom
{
get
{
return (Color) GetValue (FooterGradientBottomProperty);
}
set
{
SetValue (FooterGradientBottomProperty, value);
this.footerGradientBottom.Color = value;
}
}
private static void FooterGradientBottom_Changed (object sender,
DependencyPropertyChangedEventArgs args)
{
((subItem) sender).FooterGradientBottom = (Color) args.NewValue;
}
The Style-item, which shall be changed by the DPs was defined in XAML like this:
<code>
...
<GradientStop x:Name="footerGradientBottom" Offset="1"/>
...
</code>
Finally I assign Styles (from the static resource) to the UserControl in following way:
<code>
this.Style = (Style) this.FindResource ("HighlightedStyle");
</code>
As mentioned, the first Style is applied properly, all following assignments are without effect.
Has somebody an idea why?
Many thanks in advance,
Alex
modified on Tuesday, January 15, 2008 3:35:20 AM
|
|
|
|
|
I have created a windows application using C# and I am trying to send an email from this code. I have configured the SMTP server on the same machine on which the application resides through IIS, though the mail server is different (some different IP). The mail application runs but, no mail is sent and an error message is received.
Kindly Help
-----Have A Nice Day-----
|
|
|
|
|
assiduous wrote: no mail is sent and an error message is received.
What error message are you getting???
|
|
|
|
|
Sorry for the delay.
The error message I am getting is "Failure Sending Email..."
-----Have A Nice Day-----
|
|
|
|
|
|
Hi all,
I'm trying to set the color property of a listbox control to a custom color, more specificly:
Blue: 178
Green: 169
Red: 162
#A2A9B2
How can I do this?
Many thanks in advacne
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
<br />
using System.Drawing<br />
<br />
ListBox.BackColor=Color.FromArgb(178, 169, 162);<br />
|
|
|
|
|
|
Hi,
Any idea how to compile to an older version of .net??
I'm running VS 2005 and I'm using CSharpCodeProvider to compile some code however; I want it to be compiled to an older .net version (ie 1.1).. Any idea how to do it even in a tricky way?? maybe by importing that library from .net 1.1, please help guys
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
Looks helpful, thanks Dave!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|