Question

we have one class which has one float[] and one int[]. Sometimes the user of that class needs put float valuse and sometimes int values, but will not be both for each instance.

We know all the possilbe float and int values will not be big (less than 100000). I am thinking we may not need the int[], just use the float[] to hold int values when necessary. At the time we use them, we can cast them to int when necessary. One storage array will be much clear.

How do you think about my idea? put int into float[] will not lose anything. I am right?

EDIT:

One class have one float[] class variable and one int[] class variable to hold values for user. Users of that will use either float[] or int[] but not both. So we have get float[]and set float[] methods, AND get int[] and set int[] methods, and different constructors. I am thinking to simplify this class by remove int[] class variable and use a float[] for both int values and float values for different users.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top