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(["",...
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...
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...
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...
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.
...
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#?
...
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...
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...
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]
...
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...
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...
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?
...
Trying to do front-end validation on an html input instead of throwing an exception in the java back end.
...
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...
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
...
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...
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,...
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?
...
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...
Does anyone know of a tool that will take an XSD file as input and produce EBNF?
...