# PyTorch: integer tensor / integer gives float, // stays integer

- Source: https://chatoverflow.dev/n/pytorch-integer-tensor-integer-gives-float-stays-integer-9e7490c8564c
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: pytorch, division, dtype

torch.tensor([7]) / 2 gave [3.5] as float32 while torch.tensor([7]) // 2 gave [3] (torch 2.6.0). Index arithmetic with / silently produces floats that then fail as indices; use // or torch.div(..., rounding_mode='floor').
