fllwr Posted June 23, 2020 Share Posted June 23, 2020 e.g. ((1592891810914 / 1000) == 1592891810) evaluates to true in GG Obviously this is not the default behavior of Lua 5.3. GG 99.0, arm64 GG_logcat_r99.0_16126_9_28.log.7z In addition to broken division, converting fp number to string yields different result in GG. print(1592891810914 * 0.001) gives out "1.592891810914E9" in GG, though it is "1592891810.914" in every other lua console I used. Link to comment Share on other sites More sharing options...
Administrators Enyby Posted June 23, 2020 Administrators Share Posted June 23, 2020 Like in Java, first operand define type of operation. So you need make it float: ((1592891810914.0 / 1000) == 1592891810) -- false In the second case it is same. 1.592891810914E9 == 1592891810.914 Link to comment Share on other sites More sharing options...
fllwr Posted June 23, 2020 Author Share Posted June 23, 2020 1 hour ago, Enyby said: Like in Java, first operand define type of operation. So you need make it float: ((1592891810914.0 / 1000) == 1592891810) -- false In the second case it is same. 1.592891810914E9 == 1592891810.914 It doesn't make sense and violates Lua manual, because Lua has separate int-div // and fp-div /. (and no formal way to convert between int/fp) I tested it in other Lua 5.3 build: ((1592891810914 / 1000) == 1592891810) => false print(1592891810914 * 0.001) => "1592891810.914" 1.592891810914E9 == 1592891810.914 is a problem: it means string conversion is incompatible with other Lua build. (e.g. serialization creates different output) >> ((1592891810914.0 / 1000) == 1592891810) -- false This is not even a workaround because in practice, since variables could be int or fp. Maybe +.0 or + -.0 can convert int to fp for variables... Link to comment Share on other sites More sharing options...
Administrators Enyby Posted June 23, 2020 Administrators Share Posted June 23, 2020 Serialization number to string is implementation specific. Yes. You can do 0.0 + int_var for get float var. First variable define type of result. Link to comment Share on other sites More sharing options...
Question
fllwr
e.g. ((1592891810914 / 1000) == 1592891810) evaluates to true in GG
Obviously this is not the default behavior of Lua 5.3.
GG 99.0, arm64
GG_logcat_r99.0_16126_9_28.log.7z
In addition to broken division, converting fp number to string yields different result in GG.
print(1592891810914 * 0.001) gives out "1.592891810914E9" in GG, though it is "1592891810.914" in every other lua console I used.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.