Search Results

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

Page 98/1488 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • Converting to Base 10

    - by incrediman
    Hi, Let's say I have a string or array which represents a number in base N, N1, where N is a power of 2. Assume the number being represented is larger than the system can handle as an actual number (an int or a double etc). How can I convert that to a decimal string? I'm open to a solution for any base N which satisfies the above criteria (binary, hex, ...).

    Read the article

  • How to implement " char * ftoa(float num) " without sprintf() library function in C, C++ and JAVA

    - by SIVA
    Today I appeared for an interview, and the question was writing my own "char * ftoa(float num) " in C, C++ and Java. Yes, I know float numbers follow IEEE standard while allocating their memory, but I don't know float to char conversion by using Mantissa and Exponent in C. I don't have any idea to solve the above problem in C++ and JAVA. I/P to the ftoa(): 1.23 O/P from the ftoa(): 1.23 (char format). Thanks in advance ...

    Read the article

  • UTF-8 character encoding in Java

    - by user332523
    Hello, I am having some problems getting some French text to convert to UTF8 so that it can be displayed properly, either in a console, text file or in a GUI element. The original string is HANDICAP+ES which is supposed to be HANDICAPÉES No matter how I tried converting it, it appears the same way. Any ideas on how I can do this conversion? Thanks, Cam

    Read the article

  • Best method for converting several sets of numbers with several different ratios

    - by C Patton
    I'm working on an open-source harm reduction application for opioid addicts. One of the features in this application is the conversion (in mg/mcg) between common opioids, so people don't overdose by accident. If you're morally against opioid addiction and wouldn't respond because of your morals, please consider that this application is for HARM REDUCTION.. So people don't end up dead. I have this data.. 3mg morphine IV = 10mcg fentanyl IV 2mg morphine oral = 1mg oxycodone oral 3mg oral morphine = 1mg oxymorphone oral 7.0mg morphine oral = 1mg hydromorphone oral 1mg morphine iv = .10mg oxymorphone iv 1mg morphine oral = 1mg hydrocodone oral 1mg morphine oral = 6.67mg codeine oral 1mg morphine oral = .10mg methadone oral And I have a textbox that is the source dosage in mg (a double) that the user can enter in. Underneath this, I have radio boxes for the source substance (ie: morphine) and the destination substance (ie oxycodone) for conversion.. I've been trying to think of the most efficient way to do this, but nearly every seems sloppy. If I were to do something like public static double MorphinetoOxycodone(string morphineValue) { double morphine = Double.Parse(morphineValue); return (morphine / 2 ); } I would also have to make a function for OxycodonetoMorphine, OxycodonetoCodeine, etc.. and then would end up with dozens functions.. There must be an easier way than this that I'm missing. If you'll notice, all of my conversions use morphine as the base value.. what might be the easiest way to use the morphine value to convert one opioid to another? For example, if 1mg morphine oral is equal to 1mg hydrocodone and 1mg morphine oral is equal to .10mg methadone, wouldn't I just multiply 1*.10 to get the hydrocodone-methadone value? Implementing this idea is what I'm having the most trouble with. Any help would be GREATLY appreciated.. and if you'd like, I would add your name/nickname to the credits in this program. It's possible that many, many people around the world will use this (I'm translating it into several languages as well) and to know that your work could've helped an addict from dying.. I think that's a great thing :) -cory

    Read the article

  • Convert arbitrary size of byte[] to BigInteger[] and then safely convert back to exactly the same by

    - by PatlaDJ
    I believe conversion exactly to BigInteger[] would be optimal in my case. Anyone had done or found this written in Java and willing to share? So imagine I have arbitrary size byte[] = {0xff,0x3e,0x12,0x45,0x1d,0x11,0x2a,0x80,0x81,0x45,0x1d,0x11,0x2a,0x80,0x81} How do I convert it to array of BigInteger's and then be able to recover it back the original byte array safely? ty in advance.

    Read the article

  • Neural Networks test cases

    - by Betamoo
    Does increasing the number of test cases in case of Precision Neural Networks may led to problems (like over-fitting for example)..? Does it always good to increase test cases number? Will that always lead to conversion ? If no, what are these cases.. an example would be better.. Thanks,

    Read the article

  • Creating SVG map from geometry stored in MySQL

    - by Barnabe
    I have a group of geometries stored in MySQl (as polygon and as well-known text) representing counties. I can build a table of geometries and color codes after querying some county data (say GDP per capita). What is the best way to export this as an SVG map? I cannot find any reference to SVG conversion in the MySQL documentation.

    Read the article

  • How to convert from HTML to UTF-8 in java

    - by Llistes Sugra
    Hi, I have an ASCII String, with HTML entities, like: &agrave; &uml; &ccedil; I need this String to be without those entities and convert them into UTF-8 chars. Is there any easy way, in java to do that? Where: Clazz.method("a&agrave;","UTF-8") returns "aà" or something like that?

    Read the article

  • Convert an ArrayList to an object array

    - by marionmaiden
    Hello, Is there a command in java for conversion of an ArrayList into a object array. I know how to do this copying each object from the arrayList into the object array, but I was wondering if would it be done automatically. I want something like this: ArrayList<TypeA> a; // Let's imagine "a" was filled with TypeA objects TypeA[] array = MagicalCommand(a);

    Read the article

  • How do I convert a System::IO::Stream^ to an LPCSTR for PlaySound?

    - by Jon Cage
    I'm trying to embed and then play back a .wav file in a C++/CLI app but all the examples I've seen which use PlaySound are in VB. I can't see how to get froma Stream^ to the LPCSTR which PlaySound requires: System::IO::Stream^ s = Assembly::GetExecutingAssembly()->GetManifestResourceStream ("Ping.wav"); LPCSTR buf = s->????; PlaySound(buf, NULL, SND_ASYNC|SND_MEMORY|SND_NOWAIT); I guess I need some sort of horrible .net memory conversion magic.

    Read the article

  • Convert in-memory pdf to byte[]

    - by daft
    I'm writing a websercive in C# that will generate pdf-files and send back to the caller as a byte[]. The pdf file is generated using a third party component, but I'm struggling with the conversion. The pdf is just an in-memory object in the web service, and I can't find any good way of converting the generated pdf to a byte[] before returning it to the caller. Any advice on this?

    Read the article

  • Retrieving the first digit of a number

    - by Michoel
    Hi, I am just learning Java and am trying to get my program to retrieve the first digit of a number - for example 543 should return 5, etc. I thought to convert to a string, but I am not sure how I can convert it back? Thanks for any help. int number = 534; String numberString = Integer.toString(number); char firstLetterChar = numberString.charAt(0); int firstDigit = ????

    Read the article

  • Linq: convert string to int array

    - by Oops
    I have a function (tointarray) to convert a string into an array of ints, but I am not very satisfied with it. it does the job but there must be a more elegant way to do this, perhaps Linq could help here. unfortunately I am not very good in Linq. do you guys know a better way? my function: { string s1 = "1;2;3;4;5;6;7;8;9;10;11;12"; int[] ia = tointarray(s1, ';'); } int[] tointarray(string value, char sep) { string[] sa = value.Split(sep); int[] ia = new int[sa.Length]; for (int i = 0; i < ia.Length; ++i) { int j; string s = sa[i]; if (int.TryParse(s, out j)) { ia[i] = j; } } return ia; }

    Read the article

  • C# Modify Connection String that exists inside a library

    - by LnDCobra
    I have a Class Library, which inside just has a DataSet (MySQL connector) and a Connector class. I use this class in multiple projects to connect to the database, and I always had the password embedded in the connection string but now I need to be able to modify this string(for security purposes) so I can have the user connect using their own account. How can I modify this connection string. I have tried the following Properties.Settings.Default.DataBaseConnectionString = "String"; But it seems that the connection string is readonly becase it doesn't appear to have a setter value. I also tried the following with no luck Properties.Settings.Default.DatabaseConnectionString.Insert( Properties.Settings.Default.DatabaseConnectionConnectionString.Length - 1, "Password=dbpassword;");

    Read the article

  • HTML encode UTF-8 string gets mangled into latin1

    - by Ken Mayer
    I'm parsing my nginx logs, and I want to discover some details from the HTTP_REFERER string, for example, the query string used to find the web site. One user typed in "México" which gets encoded in the log as "query=M%E9xico". Passing this through Rack::Utils.parse_query('query=M%E9xico') you get a hash, {"query" = "M?xico"} When you to stuff "M?exico" into Postgres (but not the more forgiving SQLite), it pukes because the string isn't proper UTF-8. Looking at http://rack.rubyforge.org/doc/Rack/Utils.html#M000324, unescape is packing a hex string. How can I convert the string back to UTF-8, or can I get parse_query to return UTF-8 in the first place.

    Read the article

  • Binary to strings as binary? C #/.NET

    - by acidzombie24
    Redis keys are binary safe. I'd like to mess around and put binary into redis using C#. My client of choice doesn't support writing binary keys it uses keys and it make sense. However i am just fooling around so tell me how i can do this. How do i convert a raw byte[] into a string? At first i was thinking about converting a byte[] to a utf8 string however unicode has some checks to see if its valid or not. So raw binary should fail. Actually i tried it out. Instead of failing i got a strange result. My main question is how do i convert a raw byte[] to the equivalent string? My unimportant question is why did i get a 512 byte string instead of an exception saying this is not a valid UTF8 string? code var rainbow = new byte[256]; for (int i = 0; i < 256; i++) { rainbow[i] = (byte)i; } var sz = Encoding.UTF8.GetString(rainbow); var szarr = Encoding.UTF8.GetBytes(sz); Console.WriteLine("{0} {1} {2}", ByteArraysEqual(szarr, rainbow), szarr.Length, rainbow.Length); Output False 512 256

    Read the article

  • "Simple" Text replace function

    - by YourMomzThaBomb
    I have a string which is basically a list of "words" delimited by commas. These "words" can be pretty much any character e.g. "Bart Simpson, Ex-girlfriend, dude, radical" I'm trying to use javascript, jQuery, whatever i can to replace a word based on a search string with nothing (in essence, removing the word from the list). For example, the function is defined as such: function removeWord(myString, wordToReplace) {...}; So, passing the string listed above as myString and passing "dude" as wordToReplace would return the string "Bart Simpson, Ex-girlfriend, radical" Here's the line of code I was tinkering around with...please help me figure out what's wrong with it or some alternative (better) solution:$myString.val($myString.val().replace(/wordToReplace\, /, ""));

    Read the article

  • c# reading integer fields from database, returning empty string when reading integer type field

    - by arnoldino
    what is wrong with this code? field="id"; table="MInvMonth"; condition="machine_id=37"; public static String getConditionedField(String field, String table, String condition) try { if (cmd == null) getConnection(); cmd.CommandText = "Select " + field + " from " + table + " where " + condition; SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows==true) { reader.Read(); string s = reader[0].ToString(); // return first element reader.Close(); return s; } reader.Close(); return null; } catch (Exception e) { MessageBox.Show("Caught exception: " + e.Message+"|"+cmd.CommandText); return null; } I checked the sql statement, it turns the right value. why can't I read it? the returnvalue is "".

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >