Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 154/1488 | < Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >

  • What is the best way to convert this java code into Objective C code??

    - by LCYSoft
    public byte[] toBytes() { size = 12; ByteBuffer buf = ByteBuffer.allocate(size); buf.putInt(type.ordinal());//type is a enum buf.putInt(id); buf.putInt(size); return buf.array(); } @Override public void fromBytes(byte[] data) { ByteBuffer buf = ByteBuffer.allocate(data.length); buf.put(data); buf.rewind(); type = MessageType.values()[buf.getInt()]; id = buf.getInt(); size = buf.getInt(); } Thanks in advance :)

    Read the article

  • how to load c# object side by side

    - by mamu
    We have serialized value of some objects persisted. Now we want to make substantial changes to some objects. So what i want to do is load older version of object using old assembly then deserialize and serialize again with newer version of the object. I can have convert method which can transform old object to new one. i have been converting object on fly on deserializer but in this case it's almost new object with same name.

    Read the article

  • Using pow() for large number

    - by g4ur4v
    I am trying to solve a problem, a part of which requires me to calculate (2^n)%1000000007 , where n<=10^9. But my following code gives me output "0" even for input like n=99. Is there anyway other than having a loop which multilplies the output by 2 every time and finding the modulo every time (this is not I am looking for as this will be very slow for large numbers). #include<stdio.h> #include<math.h> #include<iostream> using namespace std; int main() { unsigned long long gaps,total; while(1) { cin>>gaps; total=(unsigned long long)powf(2,gaps)%1000000007; cout<<total<<endl; } }

    Read the article

  • How to convert value of Generic Type Argument to a concrete type?

    - by Aleksey Bieneman
    I am trying to convert the value of the generic type parameter T value into integer after making sure that T is in fact integer: public class Test { void DoSomething<T>(T value) { var type = typeof(T); if (type == typeof(int)) { int x = (int)value; // Error 167 Cannot convert type 'T' to 'int' int y = (int)(object)value; // works though boxing and unboxing } } } Although it works through boxing and unboxing, this is an additional performance overhead and i was wandering if there's a way to do it directly. Thank you!

    Read the article

  • Whats the easiest way to convert a long in C to a char*?

    - by dh82
    What is the clean way to do that in C? wchar_t* ltostr(long value) { int size = string_size_of_long(value); wchar_t *wchar_copy = malloc(value * sizeof(wchar_t)); swprintf(wchar_copy, size, L"%li", self); return wchar_copy; } The solutions I came up so far are all rather ugly, especially allocate_properly_size_whar_t uses double float base math.

    Read the article

  • Which Perl moudle can handle variety of date formats with unicode characters ?

    - by ram
    My requirement is parsing xml files which contains wide varieties of timestamps based on the locales at which they are written. They may contain Unicode characters in case of Chinese or Korean locales. I have to parse these timestamps and put then in a standard format something like 2009-11-26 12:40:54 to put them in a oracle database. Sometimes I may not even know the locale and yet I have to parse the timestamps. I am looking for a module that automatically detects the timestamp format (including unicode characters for am and pm in their local language) and converts in to epoch time so that I can convert it back to what ever way I like to. I have gone through similar questions in this forum. Few suggested DateFormat module, and Date::Parse module. The perl distribution I am using is 5.10 so Date::Manip doesn't come as a core module. As I am supposed to use just the basic core modules and few CPAN modules(on request I cannot ask for all), I request you to kindly suggest me a good module that suffices all my requirements. Thanks in advance

    Read the article

  • Why do Java and C# not have implicit conversions to boolean?

    - by Shaun
    Since I started Java it's been very aggravating for me that it doesn't support implicit conversions from numeric types to booleans, so you can't do things like: if (flags & 0x80) { ... } instead you have to go through this lunacy: if ((flags & 0x80) != 0) { ... } It's the same with null and objects. Every other C-like language I know including JavaScript allows it, so I thought Java was just moronic, but I've just discovered that C# is the same (at least for numbers, don't know about null/objects): http://msdn.microsoft.com/en-us/library/c8f5xwh7(VS.71).aspx Microsoft changed it on purpose from C++, so why? Clearly I'm missing something. Why change (what I thought was) the most natural thing in the world to make it longer to type? What on Earth is wrong with it?

    Read the article

  • Urgent help! how do i convert this?..

    - by sil3nt
    Hey there, this is part of a question i got in class, im at the final stretch but this has become a major problem. In it im given a certain value which is called the "gold value" and it is 40.5, this value changes in input. and i have these constants const int RUBIES_PER_DIAMOND = 5; // relative values. * const int EMERALDS_PER_RUBY = 2; const int GOLDS_PER_EMERALDS = 5; const int SILVERS_PER_GOLD = 4; const int COPPERS_PER_SILVER = 5; const int DIAMOND_VALUE = 50; // gold values. * const int RUBY_VALUE = 10; const int EMERALD_VALUE = 5; const float SILVER_VALUE = 0.25; const float COPPER_VALUE = 0.05; which means that basically for every diamond there are 5 rubies, and for every ruby there are 2 emeralds. So on and so forth. and the "gold value" for every diamond for example is 50 (diamond value = 50) this is how much one diamond is worth in golds. my problem is converting 40.5 into these diamonds and ruby values. I know the answer is 4rubies and 2silvers but how do i write the algorithm for this so that it gives the best estimate for every goldvalue that comes along?? please help!, im at my wits end

    Read the article

  • Pitfalls when converting C++/CLI to C++

    - by directedition
    I have a library written in C++/CLI and I want to open it up. I want it to be as cross-platform as possible and be able to write bindings to it for other languages to use (Java, Python, etc, etc). To do this, the library needs to be in plain C++ for maximum flexibility. I figure that the logical structures are already there, I just need to replace the .NET libraries it uses with the standard C++ ones. Is this a misguided notion? What should I watch out for when making this transition?

    Read the article

  • How to use use external js in typescript

    - by Krishan
    I Generate the Angular JS code through the Typescript code. In one situation, I need to add external JS file to my typescript file and need to access the classes in the js file. I add that js file like this. /// <amd-dependency path="../../vendor/tweenMax.js" /> But still the typescript file can not identify the objects of that javascript file. If someone knows the suitable way, please add your answer. (I'm using min. js file)

    Read the article

  • Java to C++ converter/tool

    - by n00ki3
    Hi I always asked myself if it would be possible to make a Java2C++ Converter. Maybe a Tool that converts the Java Syntax to the C++ Syntax.. i am aware that the languages differ .. but simple things like loops where the semantic matches 1 on 1 .. is there such a tool . or is it possible to make one ?

    Read the article

  • g++ compiler complains about conversions between relative types (from int to enum, from void* to cla

    - by Slav
    g++ compiler complains about conversions between relative types (from int to enum, from void* to class*, from const char* to unsigned char*, etc.). Compiler handles such convertions as errors and won't compile furthermore. It occurs only when I compile using Dev-C++ IDE, but when I compile the same code (using the compiler which Dev-C++ uses) such errors (even warnings) do not appears. How to mute errors of such types?

    Read the article

  • Convert webpage to image from ASP.NET

    - by Nissan Fan
    I would like to create a function in C# that takes a specific webpage and coverts it to a JPG image from within ASP.NET. I don't want to do this via a third party or thumbnail service as I need the full image. I assume I would need to somehow leverage the webbrowser control from within ASP.NET but I just can't see where to get started. Does anyone have examples?

    Read the article

  • How to convert Vector Layer coordinates into Map Latitude and Longitude in Openlayers.

    - by Jenny
    I'm pretty confused. I have a point: x= -12669114.702301 y= 5561132.6760608 That I got from drawing a square on a vector layer with the DrawFeature controller. The numbers seem...erm...awfull large, but they seem to work, because if I later draw a square with all the same points, it's in the same position, so I figure they have to be right. The problem is when I try to convert this point to latitude and longitude. I'm using: map.getLonLatFromPixel(pointToPixel(points[0])); Where points[0] is a geometry Point, and the pointToPixel function takes any point and turns it into a pixel (since the getLonLatFromPixel needs a pixel). It does this by simply taking the point's x, and making it the pixels x, and so on. The latitude and longitude I get is on the order of: lat: -54402718463.864 lng: -18771380.353223 This is very clearly wrong. I'm left really confused. I try projecting this object, using: .transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); But I don't really get it and am pretty sure I did it incorrectly, anyways. My code is here: http://pastie.org/909644 I'm sort of at a loss. The coordinates seem consistent, because I can reuse them to get the same result...but they seem way larger than any of the examples I'm seeing on the openLayers website...

    Read the article

  • Is it guaranteed that new Integer(i) == i in Java?

    - by polygenelubricants
    Consider the following snippet: int i = 99999999; byte b = 99; short s = 9999; Integer ii = Integer.valueOf(9); // should be within cache System.out.println(new Integer(i) == i); // "true" System.out.println(new Integer(b) == b); // "true" System.out.println(new Integer(s) == s); // "true" System.out.println(new Integer(ii) == ii); // "false" It's obvious why the last line will ALWAYS prints "false": we're using == reference identity comparison, and a new object will NEVER be == to an already existing object. The question is about the first 3 lines: are those comparisons guaranteed to be on the primitive int, with the Integer auto-unboxed? Are there cases where the primitive would be auto-boxed instead, and reference identity comparisons are performed? (which would all then be false!)

    Read the article

  • How to go about writing this classic asp in asp.net

    - by Phil
    I am stuck in converting this snipped to asp.net. set RSLinksCat = conn.Execute("select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid = links.id and contentlinks.contentid = " & contentid & " and links.linkscatid = linkscat.id order by linkscat.category") <%if not RSLinksCat.EOF then%><h1>Links</h1> <br /> <%do while not RSLinksCat.EOF%> <%set RSLinks = conn.Execute("select * from links where linkscatid = " & RSLinksCat("id") & "")%> <strong><%=RSlinkscat("category")%><strong> <ul> <%do while not RSlinks.EOF%> <li> <a href = "http://<%=RSLinks("url")%>" target="_blank"><%=RSlinks("description")%></a> </li> <%RSLinks.MoveNext loop%> </ul> <%RSLinksCat.MoveNext loop%> <br /> <%end if%><%conn.close%> I'm not sure where to start. Can anyone recommend the correct approach i.e sqldatareaders or repeaters or arrays or? VB code samples most welcome. Thanks

    Read the article

  • How do I change the class of an object to a subclass of its current class in C++?

    - by Jared P
    I have an array of pointers to a base class, so that I can make those pointers point to (different) subclasses of the base class, but still interact with them. (really only a couple of methods which I made virtual and overloaded) I'm wondering if I can avoid using the pointers, and instead just make an array of the base class, but have some way to set the class to the subclass of my choosing. I know there must be something there specifying the class, as it needs to use that to look up the function pointer for virtual methods. By the way, the subclasses all have the same ivars and layout. Note: the design is actually based on using a template argument instead of a variable, due to performance increases, so really the abstract base class is just the interface for the subclasses, which are all the same except for their compiled code. Thanks

    Read the article

  • Why does Option not extend the Iterable trait directly?

    - by oxbow_lakes
    Option is implicitly convertible to an Iterable - but why does it not just just implement Iterable directly: def iterator = new Iterator[A] { var end = !isDefined def next() = { val n = if (end) throw new NoSuchElementException() else get end = true n } def hasNext = !end } EDIT: In fact it's even weider than that because in 2.8 Option does declare an iterator method: def iterator: Iterator[A] = if (isEmpty) Iterator.empty else Iterator.single(this.get)

    Read the article

  • Automatically converting an A* into a B*

    - by Xavier Nodet
    Hi, Suppose I'm given a class A. I would like to wrap pointers to it into a small class B, some kind of smart pointer, with the constraint that a B* is automatically converted to an A* so that I don't need to rewrite the code that already uses A*. I would therefore want to modify B so that the following compiles... struct A { void foo() {} }; template <class K> struct B { B(K* k) : _k(k) {} //operator K*() {return _k;} //K* operator->() {return _k;} private: K* _k; }; void doSomething(A*) {} void test() { A a; A* pointer_to_a (&a); B<A> b (pointer_to_a); //b->foo(); // I don't need those two... //doSomething(b); B<A>* pointer_to_b (&b); pointer_to_b->foo(); // 'foo' : is not a member of 'B<K>' doSomething(pointer_to_b); // 'doSomething' : cannot convert parameter 1 from 'B<K> *' to 'A *' } Note that B inheriting from A is not an option (instances of A are created in factories out of my control)... Is it possible? Thanks.

    Read the article

  • How to prevent CAST errors on SSIS ?

    - by manitra
    Hello, The question Is it possible to ask SSIS to cast a value and return NULL in case the cast is not allowed instead of throwing an error ? My environment I'm using Visual Studio 2005 and Sql Server 2005 on Windows Server 2003. The general context Just in case you're curious, here is my use case. I have to store data coming from somewhere in a generic table (key/value structure with history) witch contains some sort of value that can be strings, numbers or dates. The structure is something like this : table Values { Id int, Date datetime, -- for history Key nvarchar(50) not null, Value nvarchar(50), DateValue datetime, NumberValue numeric(19,9) } I want to put the raw value in the Value column and try to put the same value in the DateValue column when i'm able to cast it to Datetime in the NumberValue column when i'm able to cast it to a number Those two typed columns would make all sort of aggregation and manipulation much easier and faster later. That's it, now you know why i'm asking this strange question. ============ Thanks in advance for your help.

    Read the article

< Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >