Fix #410: x.toByte and x.toShort should ensure the proper range.