summary refs log tree commit diff stats
path: root/tests/misc/tcharinc.nim
blob: 1b5d19c18f8199dd06da3be3000fa686a352d105 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
discard """
  output: "1"
"""

var c = '\0'
while true:
  if c == '\xFF': break
  inc c

echo "1"
rranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ONE_KB = 1024 UNITS = 'BKMGTP' MAX_EXPONENT = len(UNITS) - 1 def human_readable(byte, seperator=' '): import math if not byte: return '0' exponent = int(math.log(byte, 2) / 10) flt = float(byte) / (1 << (10 * exponent)) if exponent > MAX_EXPONENT: return '>9000' # off scale if int(flt) == flt: return '%.0f%s%s' % (flt, seperator, UNITS[exponent]) else: return '%.2f%s%s' % (flt, seperator, UNITS[exponent])