FrexpFunction.cs 531 B

12345678910111213141516171819
  1. namespace Lua.Standard.Mathematics;
  2. public sealed class FrexpFunction : LuaFunction
  3. {
  4. public static readonly FrexpFunction Instance = new();
  5. public override string Name => "frexp";
  6. protected override ValueTask<int> InvokeAsyncCore(LuaFunctionExecutionContext context, Memory<LuaValue> buffer, CancellationToken cancellationToken)
  7. {
  8. var arg0 = context.GetArgument<double>(0);
  9. var (m, e) = MathEx.Frexp(arg0);
  10. buffer.Span[0] = m;
  11. buffer.Span[1] = e;
  12. return new(2);
  13. }
  14. }