24 questions
-1 votes
2 answers
186 views
How may I convert a three-digit Arabic number (Perl [0-9][0-9][0-9]) to a three-digit English representation ([zero-nine][zero-nine][zero-nine])
The alternative is to use Roman numerals, for which a package is available. I am using the LaTeX catchfile package and the \input{} command to associate a title in a set of TITLE files with \section{}...
2 votes
3 answers
705 views
Is there a purpose to using boost::numeric_cast<double>(long) (i.e., converting from long to double)?
I thought that this conversion cannot fail. So boost::numeric_cast<double>(long) should produce the same result as just a regular cast. Is this correct? If so, why is the boost::numeric_cast ...
0 votes
1 answer
206 views
How do I stop implicit date conversion when using ifelse with date time data? [duplicate]
I have a data frame that contains one column that is a series of dates, collected via a Google form. The date and time were collected separately. The data was entered by selecting a day from a ...
0 votes
2 answers
317 views
Error converting varchar to numeric (but there's no number)
I have a table with several columns, like this: CREATE TABLE CRM.INFO_ADICIONAL ( ID_INFO_ADICIONAL NUMBER(10) NOT NULL, NOMBRE VARCHAR2(100 BYTE) NOT NULL, ...
27 votes
2 answers
35k views
Best practice in C++ for casting between number types [duplicate]
What is the best practice for casting between the different number types? Types float, double, int are the ones I use the most in C++. An example of the options where f is a float and n is a double ...
9 votes
3 answers
12k views
XSLT Compare Numbers as Strings
Background I was recently surprised to notice that XSL was able to intelligently handle numbers; i.e. knowing to treat numbers in text as numeric when performing comparisons (i.e. it understood that ...
1 vote
1 answer
3k views
How do I convert the value of a TextView to integer
I am designing a basic BMI calculator and I have the calculator working, but I need to convert the calculated answer from a TextView which is a double to an integer to enable me right statements with ...
2 votes
0 answers
61 views
swift 2.0 NSDecimalNumber possible discrepency converting to long
I can't make heads or tails of this. I am using NSDecimalNumber to truncate the fractional portion from a string. This works in most cases, but not apparently in the case of infinite decimals (or ...
258 votes
6 answers
19k views
Why is 0 < -0x80000000?
I have below a simple program: #include <stdio.h> #define INT32_MIN (-0x80000000) int main(void) { long long bal = 0; if(bal < INT32_MIN ) { printf("Failed!!!")...
0 votes
1 answer
99 views
convert factor to numeric in bash
What's the most efficient way to convert a factor vector (not all levels are unique) into a numeric vector in bash? The values in the numeric vector do not matter as long as each represents a unique ...
0 votes
2 answers
3k views
C++ void reverse function
We are converting base 10 to a number in a different base(B). I am having trouble with the void reverse function it will not reverse the order of the numbers. string convertToBaseB(int num, int b){ ...
82 votes
7 answers
6k views
Is it more efficient to perform a range check by casting to uint instead of checking for negative values?
I stumbled upon this piece of code in .NET's List source code: // Following trick can reduce the range check by one if ((uint) index >= (uint)_size) { ThrowHelper....
0 votes
1 answer
3k views
How to convert UInt64 to Int64? [duplicate]
The second argument in this function call: dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC) causes the compiler error: 'UInt64' is not convertible to 'Int64' Swift Reference: func dispatch_time(when: ...
1 vote
3 answers
144 views
Type aware string to number conversion in C++
Let's assume all the numbers in this world are positive integers and they can be represented by uintX_t C++ types. Let's consider next awesome code to convert a std::string to a number: #include <...
2 votes
0 answers
3k views
.NET Double storage in DataTable?
.NET looks like it's formatting a double inside a DataRow in the wrong format, so i can't load it in a second moment. If I store "0.000000001", .NET stores it as "1E-09.0", when it should be "1E-09". ...