gpuR icon indicating copy to clipboard operation
gpuR copied to clipboard

Integer Division

Open cdeterman opened this issue 8 years ago • 0 comments

Starting to look at implementing the integer operations. Most should be straightforward, however, integer division provides an interesting situation. In R, integer division is usually done with %/%. So should the operation on an integer object be upcast to float/double if using the / operator?

For example, in base R

as.integer(c(5,4,3,6,7))/2L
[1] 2.5 2.0 1.5 3.0 3.5

Is this preferred or would it be better to have the functions assume the users wants to keep an integer object in the result

a=gpuVector(c(5,4,3,6,7),type='integer')
d=a/2
d[]
[1] 2 2 1 3 3

I'm not sure at the moment.

cdeterman avatar Jun 21 '17 20:06 cdeterman