Change floats to ints recursively on env encoding

Fixes #6246
Closes #6248

Already 2 LGTMs in  #6248