Search Results

Search found 21759 results on 871 pages for 'int'.

Page 9/871 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Using setters On Int?

    - by fuzzygoat
    Just curious, given: unsigned int pulseCounter_001; @property(nonatomic, assign)unsigned int pulseCounter_001; @synthesize pulseCounter_001; Is there any reason to use: [self setPulseCounter_001:0]; Or just use: pulseCounter_001 = 0; Style wise I think the latter says "we are setting an int" better, just curious as to any overheads involved in each? gary

    Read the article

  • Trying to get distinct values from two List<int> objects

    - by Mario
    I have 2 List objects: List<int> lst1 = new List<int>(); List<int> lst2 = new List<int>(); Let's say they have values: lst1.Add(1); lst1.Add(2); lst1.Add(3); lst1.Add(4); lst2.Add(1); lst2.Add(4); I need to get an object containing the "distinct" list of both of these; so in this case the return would be List {2, 3}. Is there an easy way to do this? Or do I need to iterate through each value of the lists and compare? I am open to using ObjectQuery, LINQ, etc as these lists are coming from a database, and could potentially be several hundred to several thousand entries long. Thanks!

    Read the article

  • Ninject: Controller Constructor with int argument

    - by Fleents
    How can you instantiate a Controller that has an int argument? Using Ninject.. My HomeController has a constructor like this: private int _masterId; Public HomeController(int masterId){ _masterId = masterId; } I created a controller factory like this: public class NinjectControllerFactory : DefaultControllerFactory { IKernel kernel = new StandardKernel(new ExampleConfigModule()); protected override IController GetControllerInstance(Type controllerType) { return controllerType == null ? null : (IController)kernel.Get(controllerType, 1); } }

    Read the article

  • How to use Delegate in C# for Dictionary<int, List<string>>

    - by Emanuel
    The code: private delegate void ThreadStatusCallback(ReceiveMessageAction action, Dictionary<int, List<string>> message); ... Dictionary<int, List<string>> messagesForNotification = new Dictionary<int, List<string>>(); ... Invoke(new ThreadStatusCallback(ReceivesMessagesStatus), ReceiveMessageAction.Notification , messagesForNotification ); ... private void ReceivesMessagesStatus(ReceiveMessageAction action, object value) { ... } How can I send the two variable of type ReceiveMessageAction respectively Dictionary<int, List<string>> to the ReceivesMessagesStatus method. Thanks.

    Read the article

  • deleting object with template for int and object

    - by Yokhen
    Alright so Say I have a class with all its definition, bla bla bla... template <class DT> class Foo{ private: DT* _data; //other stuff; public: Foo(DT* data){ _data = data } virtual ~Foo(){ delete _data } //other methods }; And then I have in the main method: int main(){ int number = 12; Foo<anyRandomClass>* noPrimitiveDataObject = new Foo<anyRandomClass>(new anyRandomClass()); Foo<int>* intObject = new Foo<int>(number); delete noPrimitiveDataObject; //Everything goes just fine. delete intObject; //It messes up here, I think because primitive data types such as int are allocated in a different way. return 0; } My question is: What could I do to have both delete statements in the main method work just fine? P.S.: Although I have not actually compiled/tested this specific code, I have reviewed it extensively (as well as indented. You're welcome.), so if you find a mistake, please be nice. Thank you.

    Read the article

  • Why toInteger :: Int -> Integer is lazy?

    - by joppux
    I have the following code: {-# NOINLINE i2i #-} i2i :: Int -> Integer i2i x = toInteger x main = print $ i2i 2 Running GHC with -ddump-simpl flag gives: [Arity 1 NoCafRefs Str: DmdType U(L)] Main.i2i = GHC.Real.toInteger1 Seems that conversion from Int to Integer is lazy. Why is it so - is there a case when I can have (toInteger _|_ ::Int) /= _|_ ?

    Read the article

  • template function roundTo int, float -> truncation

    - by Oops
    Hi, according to this question: http://stackoverflow.com/questions/2833730/calling-template-function-without-type-inference the round function I will use in the future now looks like: template < typename TOut, typename TIn > TOut roundTo( TIn value ) { return static_cast<TOut>( value + 0.5 ); } double d = 1.54; int i = rountTo<int>(d); However it makes sense only if it will be used to round to integral datatypes like char, short, int, long, long long int, and it's unsigned counterparts. If it ever will be used with a TOut As float or long double it will deliver s***. double d = 1.54; float f = roundTo<float>(d); // aarrrgh now float is 2.04; I was thinking of a specified overload of the function but ... that's not possible... How would you solve this problem? many thanks in advance Oops

    Read the article

  • [C++] Trouble declaring and recognizing global functions

    - by Sarah
    I've created some mathematical functions that will be used in main() and by member functions in multiple host classes. I was thinking it would be easiest to make these math functions global in scope, but I'm not sure how to do this. I've currently put all the functions in a file called Rdraws.cpp, with the prototypes in Rdraws.h. Even with all the #includes and externs, I'm getting a "symbol not found" error at the first function call in main(). Here's what I have: // Rdraws.cpp #include <cstdlib> using namespace std; #include <cmath> #include "Rdraws.h" #include "rng.h" extern RNG rgen // this is the PRNG used in the simulation; global scope void rmultinom( double p_trans[], int numTrials, int numTrans, int numEachTrans[] ) { // function 1 def } void rmultinom( const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]) { // function 2 def } int rbinom( int nTrials, double pLeaving ) { // function 3 def } // Rdraws.h #ifndef RDRAWS #define RDRAWS void rmultinom( double[], int, int, int[] ); void rmultinom( const double[], const int, int, int[] ); int rbinom( int, double ); #endif // main.cpp ... #include "Rdraws.h" ... extern void rmultinom(double p_trans[], int numTrials, int numTrans, int numEachTrans[]); extern void rmultinom(const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]); extern int rbinom( int n, double p ); ... int main() { ... } I'm pretty new to programming. If there's a dramatically smarter way to do this, I'd love to know.

    Read the article

  • Performance: float to int cast and clippling result to range

    - by durandai
    I'm doing some audio processing with float. The result needs to be converted back to PCM samples, and I noticed that the cast from float to int is surprisingly expensive. Whats furthermore frustrating that I need to clip the result to the range of a short (-32768 to 32767). While I would normally instictively assume that this could be assured by simply casting float to short, this fails miserably in Java, since on the bytecode level it results in F2I followed by I2S. So instead of a simple: int sample = (short) flotVal; I needed to resort to this ugly sequence: int sample = (int) floatVal; if (sample > 32767) { sample = 32767; } else if (sample < -32768) { sample = -32768; } Is there a faster way to do this? (about ~6% of the total runtime seems to be spent on casting, while 6% seem to be not that much at first glance, its astounding when I consider that the processing part involves a good chunk of matrix multiplications and IDCT)

    Read the article

  • converting tag number to int

    - by Ehtesham Sajed
    i m using Visual C++2008. i've assigned tag value=2 of all buttons from button property(using drag n drop). now i want to make some math calculation with tag value. need to change it in int. what is the default data type tag? i used this code, //code sample if(((int)this-button1-Tag)((int)this-button2-Tag)((int)this-button3-Tag)==50) { ........ //i.e, if tag value of button1*tag value of button2*tag value of button 3==50 then... ........ } generated following run time error on a messegebox An unhandled exception of type 'System.InvalidCastException' occurred in learncpp1.exe Additional information: Specified cast is not valid.

    Read the article

  • Android pass a 2d int array from one activity to another ERROR

    - by user2189001
    ACTIVITY 1: Bundle bundle = new Bundle(); bundle.putSerializable("CustomLevelData", LevelCreator.LCLevelData); Intent i = new Intent(LevelCreatorPopout.this, GameView.class); i.putExtras(bundle); startActivity(i); ACTIVITY 2: LevelData=(int[][]) extras.getSerializable("CustomLevelData"); ERROR: E/AndroidRuntime(16220): FATAL EXCEPTION: main E/AndroidRuntime(16220): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.powerpoint45.maze/com.powerpoint45.maze.GameView}: java.lang.ClassCastException: java.lang.Object[] cannot be cast to int[][] I have searched but found nothing on 2d INT array passing

    Read the article

  • Need help: input int from console and pass it into method in different class

    - by christophe
    i'm a beginner, Need help, Please!!! I want to read number "a" from console and then store them in variable to use as passing to a different class (different .java file). How do i code the 2 classes? thanks public class PassedInMethod{ private int a; . public PAssMethod(int a) { a = a; // TODO: where to get the a? System.out.println("a was passed in!"+a); } public class Mainclass{ public static void main( String args[] ){ Scanner input = new Scanner( System.in ); int a; System.out.print( "Enter your nember: " ); a = input.nextInt(); PassedInMethod(int a); }

    Read the article

  • Is new int[10]() valid c++?

    - by Naveen
    While trying to answer this question I found that the code int* p = new int[10](); compiles fine with VC9 compiler and initializes the integers to 0. So my questions are: First of all is this valid C++ or is it a microsoft extension? Is it guaranteed to initialize all the elements of the array? Also, is there any difference if I do new int; or new int();? Does the latter guarantee to initialize the variable?

    Read the article

  • c# short if statement not working with int? (int=null)

    - by kobe
    I am trying to shorten my code by using short-if: int? myInt=myTextBox.Text == "" ? null : Convert.ToInt32(myTextBox.Text); But I'm getting the following error: Type of conditional expression cannot be determined because there is no implicit conversion between '' and 'int' The following works: int? myInt; if (myTextBox.Text == "") //if no text in the box myInt=null; else myInt=Convert.ToInt32(myTextBox.Text); And if I replace the 'null' in integer (say '4') it also works: int? myInt=myTextBox.Text == "" ? 4: Convert.ToInt32(myTextBox.Text);

    Read the article

  • How Can I Get a List<int> From Linq to XML that Produces List<List<int>>?

    - by DaveDev
    I have an XML snippet as follows: <PerformancePanel> <LegalText> <Line id="300" /> <Line id="304" /> <Line id="278" /> </LegalText> </PerformancePanel> I'm using the following code to get an object: var performancePanels = new { Panels = (from panel in doc.Elements("PerformancePanel") select new { LegalTextIds = (from legalText in panel.Elements("LegalText").Elements("Line") select new List<int>() { (int)legalText.Attribute("id") }).ToList() }).ToList() }; The type of LegalTextIds is List<List<int>>. How can I get this as a List<int>?

    Read the article

  • How to extract List<int> from Dictionary<int, string>?

    - by DaveDev
    I have a method that takes a List<int>, which is a list of IDs. The source of my data is a Dictionary<int, string> where the integers are what I want a list of. Is there a better way to get this than the following code? var list = new List<int>(); foreach (var kvp in myDictionary) { list.Add(pair.Key); } ExecuteMyMethod(list);

    Read the article

  • C# cast string to enum with enum attribute

    - by rubentjeuh
    Hello, i've got the following question: I've got public enum Als { [StringValue("Beantwoord")] Beantwoord = 0, [StringValue("Niet beantwoord")] NietBeantwoord = 1, [StringValue("Geselecteerd")] Geselecteerd = 2, [StringValue("Niet geselecteerd")] NietGeselecteerd = 3, } with public class StringValueAttribute : System.Attribute { private string _value; public StringValueAttribute(string value) { _value = value; } public string Value { get { return _value; } } } And i would like to put the value from the item I selected of a combobox into a int: int i = ((int)(Als)Enum.Parse(typeof(Als), (string)cboAls.SelectedValue)); //<- WRONG Is this possible, and if so, how? (the stringvalue matches the value selected from the combobox) Thanks

    Read the article

  • Why do I get corrupt output on my file?

    - by Martin
    I have a simple program which I have compiled in both MinGW and Visual C++ 2008 Express, and both give an output file larger than 88200. When I set s = 0, both programs work as expected. What am I doing wrong? #include <fstream> using namespace std; int main(int argc, char *argv[]) { int i; short s; fstream f; f.open("test.raw", ios_base::out); for(i = 0; i < 44100; i++) { s = i & 0xFFFF; // PROBLEM? f.write(reinterpret_cast<const char *>(&s), sizeof(s)); } f.close(); return 0; }

    Read the article

  • MySQL database Int overflow and can't login in.

    - by Ryan SMith
    I have a MySQL database on my server and I"m pretty sure it's an int over flow on one table with an auto_increment field that's crashing it. I can delete the table, it's not very important, but I can't get into the server. Is there anyway to delete that database from the file system or without logging into MySQL? HELP! THE WORLD IS ENDING!

    Read the article

  • MySQL database Int overflow and can’t login in.

    - by Ryan Smith
    I have a MySQL database on my server and I"m pretty sure it's an int over flow on one table with an auto_increment field that's crashing it. I can delete the table, it's not very important, but I can't get into the server. Is there anyway to delete that database from the file system or without logging into MySQL? HELP! THE WORLD IS ENDING!

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >