Search Results

Search found 6094 results on 244 pages for 'double gras'.

Page 84/244 | < Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >

  • C# / IronPython Interop and the "float" data type

    - by Adam Haile
    Working on a project that uses some IronPython scripts to as plug-ins, that utilize functionality coded in C#. In one of my C# classes, I have a property that is of type: Dictionary<int, float> I set the value of that property from the IronPython code, like this: mc = MyClass() mc.ValueDictionary = Dictionary[int, float]({1:0.0, 2:0.012, 3:0.024}) However, when this bit of code is run, it throws the following exception: Microsoft.Scripting.ArgumentTypeException was unhandled by user code Message=expected Dictionary[int, Single], got Dictionary[int, float] To make things weirder, originally the C# code used Dictionary<int, double> but I could not find a "double" type in IronPython, tried "float" on a whim and it worked fine, giving no errors. But now that it's using float on both ends (which it should have been using from the start) it errors, and thinks that the C# code is using the "Single" data type?! I've even checked in the object browser for the C# library and, sure enough, it shows as using a "float" type and not "Single"

    Read the article

  • Unsigneds in order to prevent negative numbers

    - by Bruno Brant
    let's rope I can make this non-sujective Here's the thing: Sometimes, on fixed-typed languages, I restrict input on methods and functions to positive numbers by using the unsigned types, like unsigned int or unsigned double, etc. Most libraries, however, doesn't seem to think that way. Take C# string.Length. It's a integer, even though it can never be negative. Same goes for C/C++: sqrt input is an int or a double. I know there are reasons for this ... for example your argument might be read from a file and (no idea why) you may prefer to send the value directly to the function and check for errors latter (or use a try-catch block). So, I'm assuming that libraries are way better designed than my own code. So what are the reasons against using unsigned numbers to represent positive numbers? It's because of overflow when we cast then back to signed types?

    Read the article

  • How can i use listDictionary?

    - by Phsika
    i can fill my listdictinary but, if running error returns to me in " foreach (string ky in ld.Keys)"(invalid operation Exception was unhandled) Error Detail : After creating a pointer to the list of sample collection has been changed. C# ListDictionary ld = new ListDictionary(); foreach (DataColumn dc in dTable.Columns) { MessageBox.Show(dTable.Rows[0][dc].ToString()); ld.Add(dc.ColumnName, dTable.Rows[0][dc].ToString()); } foreach (string ky in ld.Keys) if (int.TryParse(ld[ky].ToString(), out QuantityInt)) ld[ky] = "integer"; else if(double.TryParse(ld[ky].ToString(), out QuantityDouble)) ld[ky]="double"; else ld[ky]="nvarchar";

    Read the article

  • Add up values from a text file

    - by Stanley
    Hi Guys I have a text file that contains Amounts at Substring (34, 47) of each line. I need to sum Up all the Values to the End of the File. I have this code that I had started to build but I do not know how to proceed from here: public class Addup { /** * @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException, IOException { // TODO code application logic here FileInputStream fs = new FileInputStream("C:/Analysis/RL004.TXT"); BufferedReader br = new BufferedReader(new InputStreamReader(fs)); String line; while((line = br.readLine()) != null){ String num = line.substring(34, 47); double i = Double.parseDouble(num); System.out.println(i); } } } The output is like this: 1.44576457E4 2.33434354E6 4.56875685E3 The Amount is in two decimal Places and I need the result also in the Two decimal Places. What Is the Best way to achieve this?

    Read the article

  • How to avoid translation tools from messing up HTML tags?

    - by janoChen
    I always use Google translate and paste back the the results in Vim. But for some reason Google translate also screws up the HTML tags around the content I want to translate. Is there a solution for this? For instance, the double quotes are translated to Chinese-cased double quotes: 'pictures_h2'=>“?????????? Strong and li tags are translated too (well I kinda expected that). P S : IS there any translator which respect HTML tags? or translation plugin for Vim?

    Read the article

  • Why does casting a NaN to a long yield a valid result?

    - by brainimus
    In the sample code below I am dividing by zero which when I step through it with the debugger the (dividend / divisor) yields an Infinity or NaN (if the divisor is zero). When I cast this result to a long I get a valid result, usually something like -9223372036854775808. Why is this cast valid? Why doesn't it stop executing (throw an exception for example) rather than assign an arbitrary value? double divisor = 0; double dividend = 7; long result = (long)(dividend / divisor);

    Read the article

  • troubles with integration on matlab

    - by user648666
    I'd like some help please I really need to solve this problem. Well before anything thank you for your time... My problem: I have a matrix (826x826 double) and I want to integrate this matrix with respect to a vector of (826x1 double) I don't have the functions of any of this. Is there a command or an algorithm to take the integral of a matrix with respect to a vector? Please I really need help, I'm such a newbie at matlab. Sincerely. George

    Read the article

  • c# im getting an error

    - by vj4u
    double dval = 1; for (int i = 0; i < Cols; i++) { k = 0; dval = 1; for (int j = Cols - 1; j >= 0; j--) { colIndex = (i + j) % 3; val *= dval[colIndex, k]; k++; } det -= dval; } im getting an error Cannot apply indexing with [] to an expression of type 'double' for dval help its urgent

    Read the article

  • How to use the boost lexical_cast library for just for checking input

    - by Inverse
    I use the boost lexical_cast library for parsing text data into numeric values quite often. In several situations however, I only need to check if values are numeric; I don't actually need or use the conversion. So, I was thinking about writing a simple function to test if a string is a double: template<typename T> bool is_double(const T& s) { try { boost::lexical_cast<double>(s); return true; } catch (...) { return false; } } My question is, are there any optimizing compilers that would drop out the lexical_cast here since I never actually use the value? Is there a better technique to use the lexical_cast library to perform input checking?

    Read the article

  • Haskell: Problems with overloading: Interpreter can´t tell which + to use

    - by Ben
    Hi, I want to make functions Double - Double an instance of the Num typeclass. I want to define the sum of two functions as sum of their images. So I wrote instance Num Function where f + g = (\ x - (f x) + (g x)) Here the compiler complains he can´t tell whether I´m using Prelude.+ or Module.+ in the lambda expression. So I imported Prelude qualified as P and wrote instance Num Function where f + g = (\ x - (f x) P.+ (g x)) This compiles just fine, but when I try to add two functions in GHCi the interpreter complains again he can´t tell whether I´m using Prelude.+ or Module.+. Is there any way I can solve this problem?

    Read the article

  • iPhone SKD make the iPod controller appear

    - by nico
    Hi all, It's been a while I'm consulting stackoverflow, but this time I didn't find any answer :( My question is quite simple :) On an iPhone/iPod touch, play music. Double tap the home button while the music is playing. You will see appear a popup with the play/pause/next/previous buttons and a volume control. Do you know if it's possible to make this popup appear programmatically ? I mean, I would like to add a button in my app that will display the popup, avoiding the user to double tap the home button (most of them doesn't know this shortcut). Thank you in advance !

    Read the article

  • How to access the map returned by IParameterValues::getParameterValues()?

    - by Hua
    I declared a command and a commandParameter for this command. I specified the "values" of this commandParameter as a class implemented by myself. The implementation of this class is below, public class ParameterValues implements IParameterValues { @Override public Map<String, Double> getParameterValues() { // TODO Auto-generated method stub Map<String, Double> values = new HashMap<String, Double>(2); values.put("testParam", 1.1239); values.put("AnotherTest", 4.1239); return values; } } The implementation of the handler of this command is blow, public class testHandler extends AbstractHandler implements IHandler { private static String PARAMETER_ID = "my.parameter1"; @Override public Object execute(ExecutionEvent event) throws ExecutionException { String value = event.getParameter(PARAMETER_ID); MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Test", "Parameter ID: " + PARAMETER_ID + "\nValue: " + value); return null; } } Now, I contribute the command to a menu, <menuContribution locationURI="menu:org.eclipse.ui.main.menu"> <menu id="my.edit" label="Edit"> <command commandId="myCommand.test" label="Test1"> <parameter name="my.parameter1" value="testParam"> </parameter> </command> Since I specified a "values" class for the commandParater, I expect when the menu is clicked, this code line "String value = event.getParameter(PARAMETER_ID);" in the handler class returns 1.1239 instead of "testParam". But, I still see that code line returns "testParam". What's the problem? How could I access the map returned by getParameterValues()? By the way, following menu declaration still works even I don't define "ppp" in the map. <menuContribution locationURI="menu:org.eclipse.ui.main.menu"> <menu id="my.edit" label="Edit"> <command commandId="myCommand.test" label="Test1"> <parameter name="my.parameter1" value="ppp"> </parameter> </command> Thanks!

    Read the article

  • measuring uncertainty in matlabs svmclassify

    - by Mark
    I'm doing contextual object recognition and I need a prior for my observations. e.g. this space was labeled "dog", what's the probability that it was labeled correctly? Do you know if matlabs svmclassify has an argument to return this level of certainty with it's classification? If not, matlabs svm has the following structures in it: SVM = SupportVectors: [11x124 single] Alpha: [11x1 double] Bias: 0.0915 KernelFunction: @linear_kernel KernelFunctionArgs: {} GroupNames: {11x1 cell} SupportVectorIndices: [11x1 double] ScaleData: [1x1 struct] FigureHandles: [] Can you think of any ways to compute a good measure of uncertainty from these? (Which support vector to use?) Papers/articles explaining uncertainty in SVMs welcome. More in depth explanations of matlabs SVM are also welcome. If you can't do it this way, can you think of any other libraries with SVMs that have this measure of uncertainty?

    Read the article

  • .Net Round-trip Types

    - by Fujiy
    I making a method that generate a unique string key for some parameters. But the same key if call with same values. I just accept primitive types, string, DateTime, Guid, and Nullable(since I append types together, I can distinguish who is int and who is int?), because I can convert all to string without lost values or precision.(for float and double a use ToString("R"), to DateTime ToString("O")). Exists a easy way to know which types I can transform in strings without conflict? And how do this transform(how I said before, float, double and datetime have specific ways) Thanks

    Read the article

  • Avoid Flickering in Windows Forms?

    - by user1733909
    Double buffering not working with combo-box. is there any another methods to avoid flickering in windows forms? i have one windows form with number of panels in it. I'm showing only one panel at a time based on my menu selection. i have one icon panel,one header panel and the combo box. based on the selected item of that combo-box the gridview1 and 2 are filling. when I'm rapidly selecting the combo-box item using my keyboard down arrow the icon panel and the header panel are always repainting. i need to keep that both without any change. this two panels producing some flashing effect(ie,they are blinking or flashing) while I'm changing the combo box selected index. is there any way to avoid this flashing.? i tried double-buffered enabled in form constructor and form load event. Please Help..............

    Read the article

  • Illegal Start of Expression

    - by Kraivyne
    Hello there, I have just started to learn the very basics of Java programming. Using a book entitled "Programming Video Games for the Evil Genius". I have had an Illegal Start of Expression error that I can't for the life of me get rid of. I have checked the sample code from the book and mine is identical. The error is coming from the for(int i = difficulty; i = 0; i- - ) line. Thanks for helping a newbie out. import javax.swing.*; public class S1P4 {public static void main(String[] args) throws Exception { int difficulty; difficulty = Integer.parseInt(JOptionPane.showInputDialog("How good are you?\n"+ "1 = Great\n"+"10 = Terrible")); boolean cont = false; do { cont = false; double num1 = (int)(Math.round(Math.random()*10)); double num2; do { num2 = (int)(Math.round(Math.random()*10)); } while(num2==0.0); int sign = (int)(Math.round(Math.random()*3)); double answer; System.out.println("\n\n*****"); if(sign==0) { System.out.println(num1+" times "+num2); answer = num1*num2; } else if(sign==1) { System.out.println(num1+" divided by"+num2); answer = num1/num2; } else if(sign==1) { System.out.println(num1+" plus "+num2); answer = num1+num2; } else if(sign==1) { System.out.println(num1+" minus "+num2); answer = num1-num2; } else { System.out.println(num1+" % "+num2); answer = num1%num2; } System.out.println("*****\n"); for(int i = difficulty; i >= 0; i- - ) { System.out.println(i+"..."); Thread.sleep(500); } System.out.println("ANSWER: "+answer); String again; again = JOptionPane.showInputDialog("Play again?"); if(again.equals("yes")) cont = true; } while(cont); } }

    Read the article

  • is there a way to remove duplication in this code

    - by oo
    i have a method that looks like this: private double GetX() { if (Servings.Count > 0) { return Servings[0].X; } if (!string.IsNullOrEmpty(Description)) { FoodDescriptionParser parser = new FoodDescriptionParser(); return parser.Parse(Description).X; } return 0; } and i have another method that looks like this: private double GetY() { if (Servings.Count > 0) { return Servings[0].Y; } if (!string.IsNullOrEmpty(Description)) { FoodDescriptionParser parser = new FoodDescriptionParser(); return parser.Parse(Description).Y; } return 0; } is there anyway to consolidate this as the only thing different is the property names?

    Read the article

  • What's the deal with char.GetNumericValue?

    - by mgroves
    I was working on Project Euler 40, and was a bit bothered that there was no int.Parse(char). Not a big deal, but I did some asking around and someone suggested char.GetNumericValue. GetNumericValue seems like a very odd method to me: Takes in a char as a parameter and returns...a double? Returns -1.0 if the char is not '0' through '9' So what's the reasoning behind this method, and what purpose does returning a double serve? I even fired up Reflector and looked at InternalGetNumericValue, but it's just like watching Lost: every answer just leads to another question.

    Read the article

  • Dynamic creation of a pointer function in c++

    - by Liberalkid
    I was working on my advanced calculus homework today and we're doing some iteration methods along the lines of newton's method to find solutions to things like x^2=2. It got me thinking that I could write a function that would take two function pointers, one to the function itself and one to the derivative and automate the process. This wouldn't be too challenging, then I started thinking could I have the user input a function and parse that input (yes I can do that). But can I then dynamically create a pointer to a one-variable function in c++. For instance if x^2+x, can I make a function double function(double x){ return x*x+x;} during run-time. Is this remotely feasible, or is it along the lines of self-modifying code?

    Read the article

  • Controling the visibility of a Bitmap in .NET

    - by ET
    Hi everyone, I am trying to create this simple application in c#: when the user double clicks on specific location in the form, a little circle will be drawn. By one click, if the current location is marked by a circle - the circle will be removed. I am trying to do this by simply register the MouseDoubleClick and MouseClick events, and to draw the circle from a .bmp file the following way: private void MouseDoubleClick (object sender, MouseEventArgs e) { Graphics g = this.CreateGraphics(); Bitmap myImage = (Bitmap)Bitmap.FromFile("Circle.bmp"); g.DrawImage(myImage, e.X, e.Y); } My problem is that I dont know how to make the circle unvisible when the user clicks its location: I know how to check if the selected location contains a circle (by managing a list of all the locations containig circles...), but I dont know how exactly to delete it. Another question: should I call the method this.CreateGraphics() everytime the user double-clicks a location, as I wrote in my code snippet, or should I call it once on initialization?

    Read the article

  • Could someone explain __declspec(naked) please?

    - by Scott
    I'm looking into porting a script engine written for Windows to Linux; it's for Winamp's visualization platform AVS. I'm not sure if it's even possible at the moment. From what I can tell the code is taking the addresses of the C functions nseel_asm_atan and nseel_asm_atan_end and storing them inside a table that it can reference during code execution. I've looked at MS's documentation, but I'm unsure what __declspec(naked) really does. What is prolog and epilog code mentioned in the documentation? Is that related to Windows calling conventions? Is this portable? Know of any Linux-based examples using similar techniques? static double (*__atan)(double) = &atan; __declspec ( naked ) void nseel_asm_atan(void) { FUNC1_ENTER *__nextBlock = __atan(*parm_a); FUNC_LEAVE } __declspec ( naked ) void nseel_asm_atan_end(void) {}

    Read the article

  • NoSuchMethodException while using JAVA Reflection

    - by Appps
    Hi I'm trying to use reflection to invoke a method and update the setter value of that method. But I'm getting NoSuchMethodException while ivoking that method. com.test.Test.setAddress1(java.lang.Double) .But I've this method defined in my Class. Is the problem with my code. Can someone please help me? Thanks in advance. I've my code below. Class[] doubleArrayParamTypes = new Class[ 1 ]; doubleArrayParamTypes[ 0 ] = Double.class; Class class=Class.forName( "com.test.Test"); Object voObject = class.newInstance(); String data="TestData"; performMapping(class,"setAddress1",doubleArrayParamTypes ,voObject,data); /* Reflection to set the data */ private void performMapping(Class class,String methodName,Class[] clazz,Object voObject,Object data) { class.getMethod( "set" + methodName, clazz ).invoke( voObject, data ); }

    Read the article

< Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >