conversion

How can I convert a string to a float with Perl?

Is there any function like int() which can convert a string to float value? I'm currently using the following code: $input=int(substr($line,1,index($line,",")-1)); I need to convert the string returned by substr to float. ...

How to convert array of floats to array of doubles in Java?

Hi, I have an array of floats and I would like to convert it to an array of doubles in Java. I am aware of the obvious way of iterating over the array and creating a new one. I expected Java to digest a float[] smoothly where it wishes to work with double[]... but it can not work with this. What is the elegant, effective way of d...

Problem with Informix JDBC, MONEY and decimal separator in string literals

I have problem with JDBC application that uses MONEY data type. When I insert into MONEY column: insert into _money_test (amt) values ('123.45') I got exception: Character to numeric conversion error The same SQL works from native Windows application using ODBC driver. I live in Poland and have Polish locale and in my country comma...

Good way to translate numeric to string, with decimal point removed?

Hi everyone, I have to deal with a numeric value (coming from a SQL Server 2005 numeric column) which I need to convert to a string, with the caveat that the decimal point has to be removed. The data itself is accessible in C# via a DataTable/DataRow. For example, if the SQL Server column reads 12345.678, the string should be "1234567...

convert a string to int

Hi, I have a large file where each line contains space-separated integers. The task is to sparse this file line-by-line. For the string to int conversion I have three solutions: static int stringToIntV1(const string& str) { return (atoi(str.c_str())); } However, if I pass a malformed string, it doesn't produce any error. For inst...

Hex combination of binary flags

Which of the following give back 63 as long (in Java) and how? 0x0 0x1 0x2 0x4 0x8 0x10 0x20 I'm working with NetworkManager API flags if that helps. I'm getting 63 from one of the operations but don't know how should I match the return value to the description. Thanks ...

Currency Conversion Web Service With User Input

I want to Consume a Currency Conversion Web service, Specification is, User should be able to Select Two Countries from Dropdown list on the UI, such that those values should be sent as parameters to the conversion method. How can I do this ??? ...

How does conversion operator return a value?

I am a newbie to c++ and please don't get mad at me for asking something very basic. Here's my quesion: For a class A, an integer conversion operator would look something like operator int() //Here we don't specify any return type { return intValue; } How does the above function is able to return something when its signature say...

Output RSS feed as html?

Are there any free php/javascript libraries out there which would help in displaying an RSS feed as html? ...

sql timezone calculation

I have a table which stores the storecodes and their timezone. Now based on a given local date, I need to know if that date converted to stores local date was a in a weekend or not. Now I already know how to get the weekend part. I am struggling with the conversion. I am actually confused. My table has for example the following two value...

encoding conversion tool

I would need some file encoding conversion tool, to convert some of my source files. I would need to do it as a batch, so the program needs to know to find out what's the source file encoding (Unicode - Codepage 1200) and save it as proper encoding (UTF-8), because project files are saved in different encodings. Can someone suggest me a ...

python to Java checksum calculation

I received this python script that generates a file checksum: import sys,os if __name__=="__main__": #filename=os.path.abspath(sys.argv[1]) #filename=r"H:\Javier Ortiz\559-7 From Pump.bin" cksum=0 offset=0 pfi=open(filename,'rb') while 1: icks=0 chunk=pfi.read(256) if not chunk: break #if EOF exit loop for iter in chunk: ...

Converting Some Code to jQuery

Hey guys, I have some code that I found that I would rather use as jQuery instead of direct JavaScript. Hopefully you guys can help me convert it: var sub = document.getElementById('submit'); sub.parentNode.removeChild(sub); document.getElementById('btn-area').appendChild(sub); document.getElementById('submit').tabIndex = 6; if ( typeof...

PHP typecasting float->int

Given this PHP code: // total is 71.24 (float) $value = $total * 100; var_dump($value); $valuecast = (int)$value; var_dump($valuecast); settype($value, 'int'); var_dump($value); var_dump($value) gives float(7124) var_dump($valuecast) gives int(7123) var_dump($value) after settype gives int(7123) How can I get the correct type conve...

How can I convert a Guid to a Byte array in Javascript?

I have a service bus, and the only way to transform data is via JavaScript. I need to convert a Guid to a byte array so I can then convert it to Ascii85 and shrink it into a 20 character string for the receiving customer endpoint. Any thoughts would be appreciated. ...

Is it possible to install time zones on a server?

I recently had a program fail in a production server because the server was missing a time zone, so the following line threw an exception: TimeZoneInfo.ConvertTime(date, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("Argentina Standard Time")) I fixed it exporting the time zone registry branch from a test server, importing i...

Converting RAW audio data to WAV with scripting

I have a large number of .RAW audio files (unsigned 8-bit PCM with no-endianness) which I want to convert to .WAV files. What command-line tool (windows or linux) can I use to convert these quickly? ...

C# PointF Subtract?

Was a bit shocked to discover that System.Drawing.PointF appears to have operators for subtracting sizes but not other PointFs. So I'm trying to write my own PointF class, but it needs to be able to have System.Drawing.Points automatically converted to it, or it really doesn't add any convenience. So I wrote these constructors: publ...

Python elegant inverse function of int(string,base)

python allows conversions from string to integer using any base in the range [2,36] using: int(string,base) im looking for an elegant inverse function that takes an integer and a base and returns a string for example >>> str_base(224,15) 'ee' i have the following solution: def digit_to_char(digit): if digit < 10: return chr(o...

C++ test if input is an double/char

I am trying to get input from the user and need to know a way to have the program recognize that the input was or was not a double/char this is what i have right now... but when you type an incorrect type of input 1) the double test one just loops infinatly 2) the char one won't stop looping even with the correct imput int m...