lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> On C99 systems, we used to be able to use string.format("%a", foo) for
> this, to get a hex float.  Unfortunately, some poor-quality (but
> standards-compliant) C library implementations (ie, Micorosoft's)
> explode in a sticky pile if you pass format modes they don't support,
> rather than just ignoring them.  So modern Luas check what format
> strings are used and avoiding anything that isn't in C89.

I am not sure what is your concept of modern, but at least since
version 4.0 Lua refuses unknown format modes:

  $ Lua 4.0.1  Copyright (C) 1994-2000 TeCGraf, PUC-Rio
  > print(format("%a", 13))
  error: invalid option in `format'

(Maybe you mistaken 'string.format' for ''.)

Lua 5.2 supports "%a" (and "%A") when available and reads back that
format as numerals.

-- Roberto