Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:57:35+00:00 2026-06-12T18:57:35+00:00

In Lua, using the type function on any number always returns ‘number’. Is there

  • 0

In Lua, using the type function on any number always returns ‘number’. Is there a function which can tell you whether the Lua interpreter is using a 32 bit floats, 64 bit doubles, integers or something else for the number type?

I tried to write a function like this:

function numbertype()
  local rational = 5 / 2

  if rational == 2 then
    -- equals 2
    return 'int'
  else
    -- about 2.5
    return 'double' -- but could it be a 32 bit float or something else?
  end
end

print(numbertype())

It can’t yet detect the difference between floats, doubles and unknown types. How can I query to see if Lua’s number type is equivalent to an int, float or double in Lua’s interpreter? I would like it to work in pure Lua.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:57:36+00:00Added an answer on June 12, 2026 at 6:57 pm

    Pure Lua cannot inquire about such things from the interpreter. Since the ability of the interpreter to use different types is pretty free-form (you can pick any floating-point or integral type), the only way to expose this to Lua would be to have the interpreter coded to anticipate every possible type of number that it could be compiled with.

    In general, you shouldn’t bother caring. Applications that use something other than doubles are rare at best. Even LuaJIT, which has to deal with ARM and their terrible floating-point math, still hides its ability to use integer math effectively as an optimization; Lua code can’t tell the difference.

    Which is as it should be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting out using Lua, and I was wondering (because I can't find
Say I declare a lua function using the : operator like so: function ClassName:myFunc(
I'm looking into using Lua in a web project. I can't seem to find
Lua is using colon operator ( : ) as instance method calling. Can I
I'm using the Lua 5.2 C API. I am trying to get a function
I'm using Lua, already used Google and nothing, can't find way to get string
I have a lua script which is run using the command line interpreter, the
I've registered LUA api function by using: lua_register( luaState, someFunc, aaa::someFunc); this function has
I am trying to reverse a string in Lua without using the string.reverse() function.
When using the Lua 5.2 API, the code below prints nil function __debug(szName, ...)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.