I’m trying to store float values in an array but it’s insisting that they must be stored as ‘int’.
I need to have the fractional parts utilized so even though I could convert the floats with int(float) it’s not what I’m looking for as the solution.
How can you store floats in such an array?
float dimx=800;
float dimy=850;
float[] exposure = new float[dimx*dimy]
returns error:
Type mismatch, “float” does not match with “int”
You are messing up the different elements. Let’s break it down:
float[] means that you want an array of float
exposure is the name of the array
new float[n] create an array of float containing n elements.
So you can store int, float, boolean, PVector… Anything your want.
The thing you can’t do is having n being a non integer because it makes no sense to have 2.46 elements in your array for example. Only integer values works here.
For example:
int[] intArray = new intArray[10] // create an array called intArray containing 10 integer values
float[] floatArray = new float[27] // create an array called floatArray containing 27 float values
PVector[] vectArray = new PVector[167] // create an array called vectArray containing 167 PVector
int[] intArray2 = new int[13.856] // will throw an error because 13.856 is not an integer
int[] intArray3 = new int[-56] // will throw an error because -56 is negative