Inconsistent math (flush-to-zero is random throughout execution)

I have Luau Native code generation beta enabled.

local a = function()
  return -1050
end

for i = 1, 30 do
  wait()
  print(2^a() == 0)
end

Running this results in true and false randomly:

Expected behavior

I expect this to always print false.

3 Likes

Sorry, but we cannot reproduce this issue.

If you have more information, like the system you are running this on (see How to post a Bug Report - #15 by Roblox) or if you have an example place file (if this is not on a Baseplate) - that might help.

I’m seeing this behaviour too but with a bit different results.

I thought the code is complied as native only when specifically marked as --!native, but I’m including both, what happens in scripts and what happens in the command line on my end.

No matter if code generation is enabled or disabled (regardless of the --!native comment):

  • command line: always false
  • script: first time executed in run mode → initially inconsistent, eventually quickly stabilised to true; subsequent executions in run mode → always true

I’ve heard the engine for performance reasons enables FTZ flag, so if I’m not mistaken, the tested number is subnormal and the result should always be true. The issue (if it is an issue) seems minuscule though.

System details

Studio version 0.608.1.6080485 (64bit)
Processor Intel(R) Core™ i7-6820HQ CPU @ 2.70GHz 2.71 GHz
Installed RAM 32.0 GB
System type 64-bit operating system, x64-based processor

2 Likes

Thank you for the info. We do see an issue on x64 and will be looking into it.

3 Likes