string.format hex conversion throws error
See original GitHub issueNeoLua Version: 1.3.11
Converting an integer value into a range between 0x555 and 0xFFF, fails with ‘format specifier was invalid’ If I leave the value between 0 and 255, with a 2 digit conversion, it works fine, but the moment I try a 3 digit (or 4 digit) hex conversion it fails - I’m unable to see at this point whether it’s the AT.MIN.Tools formathex or sprintf causing the issue -
Ok… I’m getting closer.
Example to reproduce:
elseif style == "HexRange" then
val = round(tonumber(Value) * 27.3) + 1365
Debug("Infodriver value before transform :" ..val)
score = string.format('%03X',tonumber(val))
Stacktrace:
9/10/2020 12:44:35 pm:SeriousError:CRITCAL ERROR:<Bold>Error Unhandled Exception:</Bold>Format specifier was invalid.
9/10/2020 12:44:35 pm:SeriousError:CRITCAL ERROR:<Bold>Trace:</Bold> at System.Number.FormatDouble(Double value, String format, NumberFormatInfo info)
at System.Double.ToString(String format, IFormatProvider provider)
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object arg0)
at AT.MIN.Tools.FormatHex(String NativeFormat, Boolean Alternate, Int32 FieldLength, Int32 FieldPrecision, Boolean Left2Right, Char Padding, Object Value) in C:\Users\scott\Documents\GitHub\neolua\NeoLua\Extern\printf.cs:line 628
at AT.MIN.Tools.sprintf(String Format, Object[] Parameters) in C:\Users\scott\Documents\GitHub\neolua\NeoLua\Extern\printf.cs:line 443
at Neo.IronLua.LuaLibraryString.format(String formatstring, Object[] args) in C:\Users\scott\Documents\GitHub\neolua\NeoLua\LuaLibraries.cs:line 353
at CallSite.Target(Closure , CallSite , Object , Object , Object )
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Why does converting between decimal and hex throw a ...
So you need to specify int instead of decimal. Because Hex format exists only for integral values. Share.
Read more >Byte32 error, even after converting string to hex
In this line, you are trying to convert complete request body in hex not a property of it, which doesn't seem a desired...
Read more >String.Format Method (System)
Converts the value of objects to strings based on the formats specified and inserts them into another string. If you are new to...
Read more >FormatException Class (System)
The exception that is thrown when the format of an argument is invalid, or when a composite format string is not well formed....
Read more >HexFormat (Java SE 17 & JDK 17)
HexFormat converts between bytes and chars and hex-encoded strings which may include additional formatting markup such as prefixes, suffixes, and delimiters ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It would be nice, if you check my changes. And let me know, if we need improvments. Or make a pull request.
You are welcome.