I have (roughly) the following code and it gives me an implicit cast error for
int fib_array = { 1, 1, 2, 3, 5, 8, 11, 19, 30 ,49, 79, 128};
if( rint(rand(65)-0.1) ){
fib_array = fib_array;
}
I cant figure out how to explicit cast the array or why the warning (error) occurs in the first place. Can somebody please help?
VEX: array implicit cast question
2184 2 0- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
- Enivob
- Member
- 2566 posts
- Joined: June 2008
- Online
Try this code.
The funny thing is, according to the documentation, rint actually returns a float, not an int. This seem wrong to me. If I am rounding a float to an int shouldn't the result simply be an int?
int fib_array[] = { 1, 1, 2, 3, 5, 8, 11, 19, 30 ,49, 79, 128}; if( int(rint(rand(65)-0.1))){ fib_array = fib_array; }
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
Ah thanks, that did it!
I even knew that rint returns a float, but I was looking for the flaw in the array bit in the following line, because that's where the compiler put the mark.
I feel like such a noob.
- I also just noticed that the slicing notation I was using in the array bit does not seem to show in the forum. Well, to clarify, if the condition was true, I would slice the array. And of course, my condition was a bit more complicated than what was shown.
I even knew that rint returns a float, but I was looking for the flaw in the array bit in the following line, because that's where the compiler put the mark.
I feel like such a noob.
- I also just noticed that the slicing notation I was using in the array bit does not seem to show in the forum. Well, to clarify, if the condition was true, I would slice the array. And of course, my condition was a bit more complicated than what was shown.
Edited by DASD - Nov. 20, 2016 13:35:17
-
- Quick Links