Skip to content

Fix an issue with casting a float to an int too soon

Kenneth Moreland requested to merge kmorel/vtk-m:cast-error into master

There was a case of bad casting where a Float32 that should be in the range between 0 and 1 was cast to an Id and then multiplied by the size of an array. The intention is to get a proportional index into the array, but because the float was cast to an int first, you get either the first or last index.

Instead, first cast the size of the array to a Float32, multiply it by the fraction, and then cast back to an Id. That should give the desired effect.

Merge request reports

Loading