Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - Cannot implicitly convert type 'double' to 'long' -


in code got above error in lines commented.

public double bigzarb(long u, long v) {     double n;     long x;     long y;     long w;     long z;     string[] = textbox7.text.split(',');     long[] nums = new long[i.length];     (int counter = 0; counter < i.length; counter++)     {         nums[counter] = convert.toint32(i[counter]);     }      u = nums[0];     int firstdigits = convert.toint32(math.floor(math.log10(u) + 1));     v = nums[1];     int seconddigits = convert.toint32(math.floor(math.log10(v) + 1));     if (firstdigits >= seconddigits)     {         n = firstdigits;      }     else     {         n = seconddigits;             }     if (u == 0 || v == 0)     {         messagebox.show("the multiply 0");     }      int intn = convert.toint32(n);     if (intn <= 3)     {         long uv = u * v;         string struv = uv.tostring();         messagebox.show(struv);         return uv;     }     else     {         int m =convert.toint32(math.floor(n / 2));          x = u % math.pow(10, m); // here         y = u / math.pow(10, m); // here         w = v % math.pow(10, m); // here         z = v / math.pow(10, m); // here          long result = bigzarb(x, w) * math.pow(10, m) + (bigzarb(x, w) + bigzarb(w, y)) * math.pow(10, m) + bigzarb(y, z);///here         textbox1.text = result.tostring();         return result;     } } 

whats problem? thanks!

the math.pow method returns double, not long need change code account this:

x = (long)(u % math.pow(10, m)); 

this code cast double result math.pow , assign value x. keep in mind lose precision providided decimal (which floating-point type , can represent decimal values). casting long truncate after decimal point.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -