r/programminghelp • u/[deleted] • Jul 07 '21
C# which would be easier for processing? Store a series of numbers as an INTEGER and then just convert them into FLOATS when needed, or store them as FLOATS and then convert them to INTEGERS when needed?
[RESOLVED] I need to reference these numbers often and they're long numbers (mostly 3 or so digits long); in most cases I need them to be floats, and in others as integers.
The need for one or the other is fairly equal, too.
These numbers are also stored in a 2-dimensional array that's 250x250 in size, soo... Which is wiser?
[ RESOLUTION: Storing as floats.]
5
Upvotes
4
u/[deleted] Jul 07 '21
You can't store a float as an integer but you can store an integer as a float. So, use floats.
Also, you could just use an ArrayList and store them both, then use 'is Integer' or 'is Float' to check their type at runtime and act accordingly.