conversion

how to convert a fraction to float in ruby

I have a string "1/16" I want to convert it to float and multiply it by 45. However, I dont get the desired results. I am trying in script/console >> "1/16".to_f => 1.0 >> "1/16".to_f*45 => 45.0 how can i get the desired result of 2.81 Bigger picture: I have a drop down like this: <%=select_tag :volume, options_for_select(["",...

How can I convert a java.util.Date object to the restricted form of the canonical representation of dateTime

I need to convert a java.util.Date variable to a representation similar to the one below. 1995-12-31T23:59:59.999Z The format for this date field is of the form 1995-12-31T23:59:59Z, and is a more restricted form of the canonical representation of dateTime http://www.w3.org/TR/xmlschema-2/#dateTime The trailing "Z" designates UTC t...

Is the MsComm ActiveX compatible with Delphi 2010?

I have ported our project from Delphi 7 to Delphi 2010. After adding some type casts now my project is running well and all the features work correctly except main functionality of the program which is bound to COM ports and the MSCOMM ActiveX component. It can read and write from a COM port but it seems something is wrong with that bec...

Python equivalent of C code from Bit Twiddling Hacks?

I have a bit counting method that I am trying to make as fast as possible. I want to try the algorithm below from Bit Twiddling Hacks, but I don't know C. What is 'type T' and what is the python equivalent of (T)~(T)0/3? A generalization of the best bit counting method to integers of bit-widths upto 128 (parameterized by type T...

ASP.NET C# Programatically convert video on the fly

I want to convert video as it is uploaded to H.264 or an alternate HQ video to play in a flash player. I would like to support as many file formats as possible. Can anyone recommend a tool. Thanks EDIT: Need to be compatible on a Windows shared hosting account. ...

Convert from Word document to HTML

I want to save the Word document in HTML using Word Viewer without having Word installed in my machine. Is there any way to accomplish this in C#? ...

convert integer to a string in a given numeric base in python

Python allows easy creation of an integer from a string of a given base via int(str,base). I want to perform the inverse: creation of a string from an integer. i.e. I want some function int2base(num,base) such that: int( int2base( X , BASE ) , BASE ) == X the function name/argument order is unimportant For any number X and ba...

How to convert from IEEE Python float to Microsoft Basic float

I got Python float value and I need to convert it in to Microsoft Basic Float (MBF) format. Luckily, Got some code from internet that does the reverse. def fmsbin2ieee(self,bytes): """Convert an array of 4 bytes containing Microsoft Binary floating point number to IEEE floating point format (which is used by Python)""" as_in...

How to convert sequence of numbers in an array to range of numbers

In javascript how to convert sequence of numbers in an array to range of numbers? eg. [2,3,4,5,10,18,19,20] to [2-5,10,18-20] ...

Deserializing json array into .net class

I'm having problems deserializing some json data, getting InvalidCastExceptions and the like. Can anyone point me in the right direction? Here's the json i'm wanting to deserialize; [{"OrderId":0,"Name":"Summary","MaxLen":"200"},{"OrderId":1,"Name":"Details","MaxLen":"0"}] Here's my code; Public Class jsTextArea Public O...

Simulating Java's Thread.sleep() in WM

Is there an easy way to make some "sleeping program" functionality by just calling function, such as it has been made in Java with Thread.sleep()? Sleep method causes, in brief, app to wait indicated time (no. of milisec.) and after that time returns to next line of code (so it "blocks" - it isn't not proper word, though - the current t...

Is there .Net TypeConverter equivalent in Java

In .NET when I had a "value" that could exist as multiple types I could easily use a TypeConverter for switching between those types (currency types, xml data vs object representation, ect). In Java, I am not sure what the preferred way to handle this situation is. Is there a TypeConverter equivalent in Java? ...

[javascript] determine if conversion from string to 32-bit integer will overflow

Trying to do front-end validation on an html input instead of throwing an exception in the java back end. ...

How to convert a Integer to a ByteString in Haskell

Hi, We'd like to serialize data in a specific binary format. We use Data.ByteStrings internally. So, the question is: How to convert the different data types we use to a ByteString. For String we have no problem, we can use encodeLazyByteString UTF8 "string". But we'd also like to convert Integers to ByteStrings (big-endian). Does any...

Windows C API for UTF8 to 1252

I'm familiar with WideCharToMultiByte and MultiByteToWideChar conversions and could use these to do something like: UTF8 -> UTF16 -> 1252 I know that iconv will do what I need, but does anybody know of any MS libs that will allow this in a single call? I should probably just pull in the iconv library, but am feeling lazy. Thanks ...

Where are the preferred argument conversions for overloaded methods documented (if at all)?

In other words, what are the precise rules for how the Java compiler determines which overloaded method to choose to execute? I've spent a good amount of time googling and I think I'm not using the right search keywords. public class C1 extends C2 {} public class C2 extends C3 {} public class C3 {} public class Test { public st...

Java and C# - byte array to long conversion difference

Hello! This is strange to me: when I run in Java byte[] data = new byte[] { 50, -106, 40, -22, -94, -119, -52, 8 }; ByteBuffer bb = ByteBuffer.wrap( data ); System.out.println( bb.getLong() ); result is 3645145936617393160 when I run in C# //unsigned values (signed&0xff) byte[] bytes = new byte[] { 50, 150, 40, 234, 162, 137, 204,...

How do I declare the size of a string array if it's a member function.

I have a problem with setting the size of my array. In my code I have: class Test { public: ....//Functions private: string name[]; }; Test() { //heres where i want to declare the size of the array } Is this possible? ...

Tool for PDF conversion to black and white

Is there a freely available (preferably open source) tool or library for PDF conversion to black and white? Some customers want to print generated PDF documents in B&W to save toner. Unfortunately I cannot generate PDF in B&W directly, since we are merging two PDF pages together, one being official not available in B&W. Update: To be m...

Tool for converting an XSD to EBNF?

Does anyone know of a tool that will take an XSD file as input and produce EBNF? ...