Is there any justifiable reason to in Java something like
Long l = new Long(SOME_CONSTANT)
This creates an extra object and is tagged by FindBugs, and is obviously a bad practice. My question is whether there is ever a good reason to do so?
I previously asked this about String constructors and got a good answer, but that answer does...
I have a Perl application that takes from command line an input as:
application --fields 1-6,8
I am required to display the fields as requested by the user on command line.
I thought of substituting '-' with '..' so that I can store them in array e.g.
$str = "1..15,16" ;
@arr2 = ( $str ) ;
@arr = ( 1..15,16 ) ;
print "@arr\n" ;
pri...
Being used to the standard way of sorting strings, I was surprised when I noticed that Windows sorts files by their names in a kind of advanced way. Let me give you an example:
Track1.mp3
Track2.mp3
Track10.mp3
Track20.mp3
I think that those names are compared (during sorting) based on letters and by numbers separately.
On the other h...
Hi everyone,
I have an 8 byte array and I want to convert it to its corresponding numeric value.
e.g.
byte[] by = new byte[8]; // the byte array is stored in 'by'
// CONVERSION OPERATION
// return the numeric value
I want a method that will perform the above conversion operation.
...
I am working with numbers a lot when editing a particular type of file, and it's mostly tedious work. The file has a format like this:
damagebase = 8.834
"abc_foo.odf" 3.77
"def_bar.odf" 3.77
"ghi_baz.odf" 3.77
"jkl_blah.odf" 4.05
...
What would you recommend for writing a script that parses this and lets me progra...
Is there a simple way to format numbers in javascript, similar to the formatting available in C# (or VB.NET) via ToString("format_provider") or String.Format()?
...
In SharePoint (MOSS 2007) search, I need to match an exact number such as 2009482842 and nothing else.
How do I get search to only return hits on the exact number?
Edit: I originally thought this was only with the SQL FullTextQuery from code, but it is also a problem when searching from the portal itself.
Edit: This was fixed by upgra...
Hello there, I am trying to convert numerical values written as words into integers. For example,
"iPhone has two hundred and thirty thousand seven hundred and eighty three apps"
would become
"iPhone as 230783 apps"
Before i start coding, I would like to know if any function / code exists for this conversion.
...
For a web application I want to be able to handle numbers up to 64 bits in size.
During testing, I found that javascript (or the browser as a whole) seems to handle as much as 17 digits. A 64-bit number has a maximum of 20 digits, but after the javascript has handled the number, the least significant 3 digits are rounded and set to 0.......
in objective-c or iphone development has anyone ever done dynamic number formatting - something along the lines of "use kCFNumberFormatterDecimalStyle until the number gets too big, then use kCFNumberFormatterScientificStyle instead?"
i want to display a number with some sort of hybrid between the two, but i'm having a little trouble wi...
as a quick test of formatting very large, precise numbers i'm doing:
(number is a synthesized NSDecimalNumber...)
number = [[NSDecimalNumber alloc] initWithDecimal:[[NSDecimalNumber numberWithDouble:420000008698643507200000.0F] decimalValue]];
DLog(@"unformatted: %@", [number stringValue]);
which gives me: "unformatted: 4200000086986...
Assume you have a variety of number or int based variables that you want to be initialized to some default value. But using 0 could be problematic because 0 is meaningful and could have side affects.
Are there any conventions around this?
I have been working in Actionscript lately and have a variety of value objects with optional param...
Hi all!
I got a pack of c++ files with static source code (already developped, not needed to do anything to them).
There is an program/lib/way to get a list of the number of params each function withing one of those files?
I mean, getting a result like:
#File a.cpp
##a() -> 3 paramss
##foo() -> 0 params (void)
#File b.cpp
##test() -...
I just basically want to switch to the number pad mode as soon a certain EditText has the focus.
...
I am designing a laboratory database. Several products, samples, etc are identified by a composite number with multiple parts which indicate different values such as: origin, date, type, id today, etc. Examples of composite numbers might include a driver's license number (X44-555-3434), lot number (XBR-A26-500-2).
How should composite...
Can this ever happen ?
3 asserts, where one should activate.
int nr = perform_calc();
assert( nr == 0);
assert( nr > 0);
assert( nr < 0);
Can there be a case when the program doesn't activate the asserts on g++ 3.4.4.
And no I don't have the possibility to change the code in order to print the number out in case the asserts don't act...
How many distinct numbers are from 1.5 x 10-45 to 3.4 x 1038 (IEE754 single precision floats)?
...
How do i convert a oracle varchar value to number
eg
table - exception
exception_value 555 where exception_value is a varchar type
I would like to test the value of exception_value column
select * from exception where exception_value = 105 instead of
select * from exception where exception_value = '105'
...
I have a number formatter set up to convert currency strings to decimal values. The problem is that if the text string does not have a leading dollar sign ("$"), it gets converted to 0, rather than a valid matching number. So:
"$3.50" converts to 3.50
"3.50" converts to 0
Here is the code for the converter:
// formatter to convert a...
Does anyone know of an elegant way to get the decimal part of a number only? In particular I am looking to get the exact number of places after the decimal point so that the number can be formatted appropriately. I was wondering if there is away to do this without any kind of string extraction using the culture specific decimal separator...