# T103

> float needs an explicit conversion to int

**Severity** Error

A `float` value is used where an `int` is required. An `int` is widened to `float` automatically, but the reverse would silently drop the fractional part, so it always has to be written out.

Round the value the way you mean it (`math.floor`, `math.round`, `math.ceil`) and convert with `int(...)`. `int` returns null for non-finite input, so add a fallback with `??` where a non-null `int` is needed.

## Failing example

```flowscope
script "Tick index"
data chart = subscribe(data.ohlcv)
state level: int = 0
pane p = pane(title: "Ticks", height: 0.2)
plot ticks = plot.line(title: "Close in ticks", on: p)
on chart.close {
  let c = chart.close ?? 0.0
  level = math.floor(c / context.tickSize)
  ticks.plot(level)
}
```

## Fixed example

```flowscope
script "Tick index"
data chart = subscribe(data.ohlcv)
state level: int = 0
pane p = pane(title: "Ticks", height: 0.2)
plot ticks = plot.line(title: "Close in ticks", on: p)
on chart.close {
  let c = chart.close ?? 0.0
  level = int(math.floor(c / context.tickSize)) ?? 0
  ticks.plot(level)
}
```

## Related

- [T101](/docs/scripting/reference/diagnostics/t101)
