Performance of Type Casting and Conversions
Hello all,
Search around these forums for ( "type casting" | "typecasting" ) and didn't scare up much. [EDIT]If I searched for the wrong thing, could you point me in the right direction?[/EDIT]
I've got a String of data which contains a decent amount of numerical fields. I'm going to try to keep everything Strings as far as that's possible, but what kind of performance surrounds type casting and conversions?
Specifically:
-------------------
int to short
/* I'd expect these next to be similar */
String to int
String to short
String to byte
/*Not sure about this one */
String to float
Thanks in advance,
--Fritzoid
Re: Performance of Type Casting and Conversions
Most modern day computers can do it so fast you wouldn't even notice. Instead, I'd focus on optimizing your algorithm instead worrying about the performance of individual commands. If you really need hi-speed performance, then Java may not be the language for you to do that task in. Note that i've run some pretty cpu intensive stuff that when I changed the algorithm has been able to reduce computation time by 100 fold or more (say, days to less than a second).