string

Regarding BigDecimal

i do the below java print command for this double variable double test=58.15; When i do a System.out.println(test); and System.out.println(new Double(test).toString()); It prints as 58.15. When i do a System.out.println(new BigDecimal(test)) I get the below value 58.14999999999999857891452847979962825775146484375 I am able to unders...

Converting an int to a binary string representation in Java?

What would be the best way (ideally, simplest) to convert an int to a binary string representation in Java? For example, say the int is 156. The binary string representation of this would be "10011100". ...

Regarding Java String dollar to cents conversion

I have a java string which has an dollar value and cents value after decimal points and starting with a + or - sign. I want to convert into cents and store it in a integer (it can have + or -). Also i need to check if the cents part (after decimal point) not more than 2 digits and throw an error message if exists example : String dollv...

Convert XmlDocument to String

Here is how I'm currently converting XMLDocument to String StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); xmlDoc.WriteTo(xmlTextWriter); return stringWriter.ToString(); The problem with this method is that if I have " ((quotes) which I have in attributes) it escapes the...

How to Split and strip into multiple variables?

How to Split and strip X string values into separate variables? X has string value of itemA=myvalue&itemB=anothervalue&itemC=andanother I have 3 strings (var1,var2,var3) to hold the values of the stripped values. Find in string X "itemA=" copy everything after "=" character until "&" character OR if no "&" character is found copy u...

php javascript ajax weird string error

I am building some html in a php script in order to send it back to a page via Ajax. $other_content = Model_Db::dbSelect($query); $div_center .= "<table>"; for($i = 0;$i<sizeof($other_content);$i++) { $div_center .= "<tr>"; $div_center .= "<td><a href='#' onclick='changediv('test','0')'>".$other...

Python Socket Send Buffer Vs. Str

I am trying to get a basic server (copied from Beginning Python) to send a str. The error: c.send( "XXX" ) TypeError: must be bytes or buffer, not str It seems to work when pickling an object. All of the examples I found, seem to be able to send a string no problem. Any help would be appreciated, Stephen import socket import pic...

Algorithm for binary arithmetic in Java

On paper, binary arithmetic is simple, but as a beginning programmer, I'm finding it a little difficult to come up with algorithms for the addition, subtraction, multiplication and division of binary numbers. I have two binary numbers stored as strings, assume that any leading zeroes have been dropped. How would I go about performing th...

Seg Fault when using std::string on an embedded Linux platform

Hi, I have been working for a couple of days on a problem with my application running on an embedded Arm Linux platform. Unfortunately the platform precludes me from using any of the usual useful tools for finding the exact issue. When the same code is run on the PC running Linux, I get no such error. In the sample below, I can reliabl...

Get decorated function object by string name

def log(func): def wraper(*a, **kw): return func(*a, **kw) return wraper @log def f(): print 'f' print locals()['f'] # - prints <function wraper at 0x00CBF3F0>. How do you get the real f object (not decorator wrap)? ...

How do you push a string with inline assembly

I know you can simply do char msg[] = "lol"; _asm { push msg } But is there a way to do it in the assembly part? _asm { push "lol" } This comes up with a compiler error I'm a beginner, be nice :P ...

python string class like stringbuilder in c#

Is there something string class like stringbuilder in c#? Thanks ...

How do I control the "long strings" compiler option?

Hello. How do I control the "long strings" compiler option? I use Delphi 2007 ...

Regarding String Manipulation

I have a string which has the below content String msg="The variables &CHAG_EF and &CHAG_DNE_DTE can be embedded in the description " String test1="22/10/2010 00:10:12" String test2 = "25/10/2010 00:01:12" I need to search the string variable msg for the value "&CHAG_EF" and if it exists replace with the value of test1 and need ...

Access to an array items ?

I have a variable that contains : Sometimes array of strings and sometimes array of array of strings e.g: var words = a LINQ to XML query; //words == { "01", "02", "03", ... } //or //words == { {"01", "02", "03"}, {"04", "05", "06"}, ... } Now , I wanna access to each item in the words array with a for statement Could you please guid...

C: Writing and Reading a string to and from a binary file.

I want to store strings in a binary file, along with a lot of other data, im using the code below (when i use it for real the strings will be malloc'd) I can write to the file. Ive looked at it in a hex editor. Im not sure im writing the null terminator correctly (or if i need to). when i read back out i get the same string length that i...

Regarding String array declaration

I have the below String assignment statement String items[] = line.split("\",\"",15); String fileNamet = items[1].replaceAll("\"","").trim(); I need to introduce a new if statement if (valid) { String items[] = line.split("\",\"",15); } else { String items[] = line.split("\",\"",16); } String fileNamet = items[1].replaceAll...

how to return the character which is at the index ?

I know that i could return the index of a particular character of a string with indexof() function. But how i could return the character with the particular index? ...

how to find a string pattern and print it from my text file using C#

i have a text file with string "abcdef" I want to search for the string "abc" in my test file ... and print the next two character for abc ..here it is "de". how i could accomplish ? which class and function? ...

Escaping a C++ string

Hey, what's the easiest way to convert a C++ std::string to another std::string, which has all the unprintable characters escaped? for example for the string of length two which the content 0x61,0x01 - the result string might be "a\x01", or "a%01" Just looking for the easiest already-implemented solution. Specific output format is les...