Different answers of calculations in LuaLaTeX on local computer, lua compiler and on overleafIn which order is Lua Code in LuaTeX being processedLuapath broke after upgrading miktexMatrix multiplication (and other operations) macro using lua moduleSymbol not found error when using Lua C .so module with LuaLaTeXLuaLaTeX: Calculate length in Lua! error: (lua): not enough memoryHow can my LaTeX files detect if they're being compiled on Overleaf?Natlib on overleaf not working properlyNesting of functions not working in lualatexIssue with xparse and lualatex

Do I need to start off my book by describing the character's "normal world"?

What is a "soap"?

What's a good pattern to calculate a variable only when it is used the first time?

How can I find files in directories listed in a file?

Bringing Power Supplies on Plane?

Units of measurement, especially length, when body parts vary in size among races

What's the point of writing that I know will never be used or read?

Locked room poison mystery!

What evidence points to a long ō in the first syllable of nōscō's present-tense form?

What are the advantages of this gold finger shape?

How to programatically get all linked items for a given Sitecore item?

Sum Square Difference, which way is more Pythonic?

How can I shoot a bow using Strength instead of Dexterity?

Are there any cons in using rounded corners for bar graphs?

Is Thieves' Cant a language?

What modifiers are added to the attack and damage rolls of this unique longbow from Waterdeep: Dragon Heist?

Sums of binomial coefficients weighted by incomplete gamma

Help, I cannot decide when to start the story

Airline power sockets shut down when I plug my computer in. How can I avoid that?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

Output the list of musical notes

How can I communicate my issues with a potential date's pushy behavior?

Weird resistor with dots around it on the schematic

Would the USA be eligible to join the European Union?



Different answers of calculations in LuaLaTeX on local computer, lua compiler and on overleaf


In which order is Lua Code in LuaTeX being processedLuapath broke after upgrading miktexMatrix multiplication (and other operations) macro using lua moduleSymbol not found error when using Lua C .so module with LuaLaTeXLuaLaTeX: Calculate length in Lua! error: (lua): not enough memoryHow can my LaTeX files detect if they're being compiled on Overleaf?Natlib on overleaf not working properlyNesting of functions not working in lualatexIssue with xparse and lualatex






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








15















Here is the code. It makes use of the file matrix.lua available at the following link.
https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



The following code is to be run by matrix.lua file in the same directory as that of tex file. It is to be compiled with LuaLaTeX engine.



documentclassarticle
begindocument
defn2,4,6,8,10,12,14,16,20
directlualocal matrix = require "matrix"
tex.sprint(matrix.latex(matrix.pow(n,50)))
enddocument


When I run the command tex.sprint(matrix.latex(matrix.pow(n,-50))). There is no problem. It runs fine and gives answer in scientific notation. So there is no problem with power -50. However with power 50, it gives absolutely wrong answer. This is definitely not issue with lua or matrix.lua. This is because when I run following commands in lua on local computer, I get correct answer.



local matrix = require "matrix"
n=2,4,6,8,10,12,14,16,20
print(matrix.latex(matrix.pow(n,50)))


I also get correct answer when I run the code on overleaf. Basically answers on lua compiler on my local computer and overleaf compiler match. But answers produced by LuaLaTeX compiler on my computer are different from lua compiler on my computer or one that on overleaf. Where is the problem then?



  1. Is there any issue with local computer? If so, how I get correct answer with power -50. I also get correct answer in lua compiler on my computer.


  2. Why answers on overleaf compiler and my local computer are different for power 50. They match for power -50.


  3. Does this issue have anything to do with capacities of local computer such as processor, operating system, 32 bits or 64 bits, ram etc.?


Note: There is some problem in the matrix.latex function of the file matrix.lua. It prints some unnecessary characters at the beginning of each row and in the last entry of the last row of the matrix. I already fixed it. But for this question, it can be neglected.










share|improve this question
































    15















    Here is the code. It makes use of the file matrix.lua available at the following link.
    https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



    The following code is to be run by matrix.lua file in the same directory as that of tex file. It is to be compiled with LuaLaTeX engine.



    documentclassarticle
    begindocument
    defn2,4,6,8,10,12,14,16,20
    directlualocal matrix = require "matrix"
    tex.sprint(matrix.latex(matrix.pow(n,50)))
    enddocument


    When I run the command tex.sprint(matrix.latex(matrix.pow(n,-50))). There is no problem. It runs fine and gives answer in scientific notation. So there is no problem with power -50. However with power 50, it gives absolutely wrong answer. This is definitely not issue with lua or matrix.lua. This is because when I run following commands in lua on local computer, I get correct answer.



    local matrix = require "matrix"
    n=2,4,6,8,10,12,14,16,20
    print(matrix.latex(matrix.pow(n,50)))


    I also get correct answer when I run the code on overleaf. Basically answers on lua compiler on my local computer and overleaf compiler match. But answers produced by LuaLaTeX compiler on my computer are different from lua compiler on my computer or one that on overleaf. Where is the problem then?



    1. Is there any issue with local computer? If so, how I get correct answer with power -50. I also get correct answer in lua compiler on my computer.


    2. Why answers on overleaf compiler and my local computer are different for power 50. They match for power -50.


    3. Does this issue have anything to do with capacities of local computer such as processor, operating system, 32 bits or 64 bits, ram etc.?


    Note: There is some problem in the matrix.latex function of the file matrix.lua. It prints some unnecessary characters at the beginning of each row and in the last entry of the last row of the matrix. I already fixed it. But for this question, it can be neglected.










    share|improve this question




























      15












      15








      15


      1






      Here is the code. It makes use of the file matrix.lua available at the following link.
      https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



      The following code is to be run by matrix.lua file in the same directory as that of tex file. It is to be compiled with LuaLaTeX engine.



      documentclassarticle
      begindocument
      defn2,4,6,8,10,12,14,16,20
      directlualocal matrix = require "matrix"
      tex.sprint(matrix.latex(matrix.pow(n,50)))
      enddocument


      When I run the command tex.sprint(matrix.latex(matrix.pow(n,-50))). There is no problem. It runs fine and gives answer in scientific notation. So there is no problem with power -50. However with power 50, it gives absolutely wrong answer. This is definitely not issue with lua or matrix.lua. This is because when I run following commands in lua on local computer, I get correct answer.



      local matrix = require "matrix"
      n=2,4,6,8,10,12,14,16,20
      print(matrix.latex(matrix.pow(n,50)))


      I also get correct answer when I run the code on overleaf. Basically answers on lua compiler on my local computer and overleaf compiler match. But answers produced by LuaLaTeX compiler on my computer are different from lua compiler on my computer or one that on overleaf. Where is the problem then?



      1. Is there any issue with local computer? If so, how I get correct answer with power -50. I also get correct answer in lua compiler on my computer.


      2. Why answers on overleaf compiler and my local computer are different for power 50. They match for power -50.


      3. Does this issue have anything to do with capacities of local computer such as processor, operating system, 32 bits or 64 bits, ram etc.?


      Note: There is some problem in the matrix.latex function of the file matrix.lua. It prints some unnecessary characters at the beginning of each row and in the last entry of the last row of the matrix. I already fixed it. But for this question, it can be neglected.










      share|improve this question
















      Here is the code. It makes use of the file matrix.lua available at the following link.
      https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



      The following code is to be run by matrix.lua file in the same directory as that of tex file. It is to be compiled with LuaLaTeX engine.



      documentclassarticle
      begindocument
      defn2,4,6,8,10,12,14,16,20
      directlualocal matrix = require "matrix"
      tex.sprint(matrix.latex(matrix.pow(n,50)))
      enddocument


      When I run the command tex.sprint(matrix.latex(matrix.pow(n,-50))). There is no problem. It runs fine and gives answer in scientific notation. So there is no problem with power -50. However with power 50, it gives absolutely wrong answer. This is definitely not issue with lua or matrix.lua. This is because when I run following commands in lua on local computer, I get correct answer.



      local matrix = require "matrix"
      n=2,4,6,8,10,12,14,16,20
      print(matrix.latex(matrix.pow(n,50)))


      I also get correct answer when I run the code on overleaf. Basically answers on lua compiler on my local computer and overleaf compiler match. But answers produced by LuaLaTeX compiler on my computer are different from lua compiler on my computer or one that on overleaf. Where is the problem then?



      1. Is there any issue with local computer? If so, how I get correct answer with power -50. I also get correct answer in lua compiler on my computer.


      2. Why answers on overleaf compiler and my local computer are different for power 50. They match for power -50.


      3. Does this issue have anything to do with capacities of local computer such as processor, operating system, 32 bits or 64 bits, ram etc.?


      Note: There is some problem in the matrix.latex function of the file matrix.lua. It prints some unnecessary characters at the beginning of each row and in the last entry of the last row of the matrix. I already fixed it. But for this question, it can be neglected.







      luatex overleaf lua luacode directlua






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 4 at 6:11







      user61681

















      asked Aug 4 at 5:41









      user61681user61681

      5292 silver badges12 bronze badges




      5292 silver badges12 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          20














          You have encountered the new integer datatype of Lua 5.3 which is part of LuaTeX 1.10.1 in TeX Live 2019. When Lua encounters a number that can be represented by a 64-bit integer, Lua will no longer convert it to a floating point number and lose precision but store it at full precision in a suitable integer type. However, when using integers you do not only get their advantages but also their disadvantages, one of them is overflow.



          For floating point numbers, if the number becomes too large to represent it just becomes inf but integers do not behave that way due to their layout in memory. If an integer becomes too large it will wrap around and become negative. You can try that out for yourself:



          $ lua5.3
          Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
          > print(9223372036854775807 + 1)
          -9223372036854775808


          That is exactly what you are seeing in your code.



          But there is a way around it. If you don't want to use integers, you don't have to. Simply tell Lua that you would like to use floating point numbers by appending a .0 to literals.



          $ lua5.3
          Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
          > print(9223372036854775807.0 + 1.0)
          9.2233720368548e+18





          share|improve this answer

























          • Can we add a command in directlua so that integers are auto converted into floats.

            – user61681
            Aug 4 at 8:16











          • @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

            – Henri Menke
            Aug 4 at 9:05


















          10














          Lua 5.3 as used in texlive 2019 luatex has a (64bit) integer type.



          You need to decide what outcome you want, and whether to use the integer or floating point 64bit types.



          The file



          a=1024*1024*1024*1024*1024*1024*1024 -- 2^70
          print(a)


          which is trying to get the integer 2^70



          produces 0 with luatex 1.10 and greater:



          $ texlua in1.lua
          0


          but with older luatex produced an approximate result:



          $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in1.lua
          1.1805916207174e+21


          So you might be tempted to fix this by casting do double, eg this version with 1.0



          a=1.0*1024*1024*1024*1024*1024*1024*1024 -- 2^70
          print(a)


          Produces 1.1805916207174e+21 on both systems.



          Note however double requires some bits to store the exponent so while it will not overflow at 2^64 it can not accurately store integers above 2^56



          Compare this file that calculates 2^60 then adds 1.



          a=1024*1024*1024*1024*1024*1024
          print(a)
          b=a+1
          print(b)
          print (a == b)


          This works in exact integer arithmetic with Lua 5.3



          $ texlua in.lua
          1152921504606846976
          1152921504606846977
          false


          but works in double arithmetic, and a final result of true rather than false, in Lua 5.2.



          $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in.lua
          1.1529215046068e+18
          1.1529215046068e+18
          true





          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "85"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f502742%2fdifferent-answers-of-calculations-in-lualatex-on-local-computer-lua-compiler-an%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            20














            You have encountered the new integer datatype of Lua 5.3 which is part of LuaTeX 1.10.1 in TeX Live 2019. When Lua encounters a number that can be represented by a 64-bit integer, Lua will no longer convert it to a floating point number and lose precision but store it at full precision in a suitable integer type. However, when using integers you do not only get their advantages but also their disadvantages, one of them is overflow.



            For floating point numbers, if the number becomes too large to represent it just becomes inf but integers do not behave that way due to their layout in memory. If an integer becomes too large it will wrap around and become negative. You can try that out for yourself:



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807 + 1)
            -9223372036854775808


            That is exactly what you are seeing in your code.



            But there is a way around it. If you don't want to use integers, you don't have to. Simply tell Lua that you would like to use floating point numbers by appending a .0 to literals.



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807.0 + 1.0)
            9.2233720368548e+18





            share|improve this answer

























            • Can we add a command in directlua so that integers are auto converted into floats.

              – user61681
              Aug 4 at 8:16











            • @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

              – Henri Menke
              Aug 4 at 9:05















            20














            You have encountered the new integer datatype of Lua 5.3 which is part of LuaTeX 1.10.1 in TeX Live 2019. When Lua encounters a number that can be represented by a 64-bit integer, Lua will no longer convert it to a floating point number and lose precision but store it at full precision in a suitable integer type. However, when using integers you do not only get their advantages but also their disadvantages, one of them is overflow.



            For floating point numbers, if the number becomes too large to represent it just becomes inf but integers do not behave that way due to their layout in memory. If an integer becomes too large it will wrap around and become negative. You can try that out for yourself:



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807 + 1)
            -9223372036854775808


            That is exactly what you are seeing in your code.



            But there is a way around it. If you don't want to use integers, you don't have to. Simply tell Lua that you would like to use floating point numbers by appending a .0 to literals.



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807.0 + 1.0)
            9.2233720368548e+18





            share|improve this answer

























            • Can we add a command in directlua so that integers are auto converted into floats.

              – user61681
              Aug 4 at 8:16











            • @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

              – Henri Menke
              Aug 4 at 9:05













            20












            20








            20







            You have encountered the new integer datatype of Lua 5.3 which is part of LuaTeX 1.10.1 in TeX Live 2019. When Lua encounters a number that can be represented by a 64-bit integer, Lua will no longer convert it to a floating point number and lose precision but store it at full precision in a suitable integer type. However, when using integers you do not only get their advantages but also their disadvantages, one of them is overflow.



            For floating point numbers, if the number becomes too large to represent it just becomes inf but integers do not behave that way due to their layout in memory. If an integer becomes too large it will wrap around and become negative. You can try that out for yourself:



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807 + 1)
            -9223372036854775808


            That is exactly what you are seeing in your code.



            But there is a way around it. If you don't want to use integers, you don't have to. Simply tell Lua that you would like to use floating point numbers by appending a .0 to literals.



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807.0 + 1.0)
            9.2233720368548e+18





            share|improve this answer













            You have encountered the new integer datatype of Lua 5.3 which is part of LuaTeX 1.10.1 in TeX Live 2019. When Lua encounters a number that can be represented by a 64-bit integer, Lua will no longer convert it to a floating point number and lose precision but store it at full precision in a suitable integer type. However, when using integers you do not only get their advantages but also their disadvantages, one of them is overflow.



            For floating point numbers, if the number becomes too large to represent it just becomes inf but integers do not behave that way due to their layout in memory. If an integer becomes too large it will wrap around and become negative. You can try that out for yourself:



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807 + 1)
            -9223372036854775808


            That is exactly what you are seeing in your code.



            But there is a way around it. If you don't want to use integers, you don't have to. Simply tell Lua that you would like to use floating point numbers by appending a .0 to literals.



            $ lua5.3
            Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
            > print(9223372036854775807.0 + 1.0)
            9.2233720368548e+18






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 4 at 6:30









            Henri MenkeHenri Menke

            82.5k9 gold badges180 silver badges298 bronze badges




            82.5k9 gold badges180 silver badges298 bronze badges















            • Can we add a command in directlua so that integers are auto converted into floats.

              – user61681
              Aug 4 at 8:16











            • @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

              – Henri Menke
              Aug 4 at 9:05

















            • Can we add a command in directlua so that integers are auto converted into floats.

              – user61681
              Aug 4 at 8:16











            • @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

              – Henri Menke
              Aug 4 at 9:05
















            Can we add a command in directlua so that integers are auto converted into floats.

            – user61681
            Aug 4 at 8:16





            Can we add a command in directlua so that integers are auto converted into floats.

            – user61681
            Aug 4 at 8:16













            @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

            – Henri Menke
            Aug 4 at 9:05





            @user61681 No, it's a Lua language feature. You could downgrade LuaTeX on your machine.

            – Henri Menke
            Aug 4 at 9:05













            10














            Lua 5.3 as used in texlive 2019 luatex has a (64bit) integer type.



            You need to decide what outcome you want, and whether to use the integer or floating point 64bit types.



            The file



            a=1024*1024*1024*1024*1024*1024*1024 -- 2^70
            print(a)


            which is trying to get the integer 2^70



            produces 0 with luatex 1.10 and greater:



            $ texlua in1.lua
            0


            but with older luatex produced an approximate result:



            $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in1.lua
            1.1805916207174e+21


            So you might be tempted to fix this by casting do double, eg this version with 1.0



            a=1.0*1024*1024*1024*1024*1024*1024*1024 -- 2^70
            print(a)


            Produces 1.1805916207174e+21 on both systems.



            Note however double requires some bits to store the exponent so while it will not overflow at 2^64 it can not accurately store integers above 2^56



            Compare this file that calculates 2^60 then adds 1.



            a=1024*1024*1024*1024*1024*1024
            print(a)
            b=a+1
            print(b)
            print (a == b)


            This works in exact integer arithmetic with Lua 5.3



            $ texlua in.lua
            1152921504606846976
            1152921504606846977
            false


            but works in double arithmetic, and a final result of true rather than false, in Lua 5.2.



            $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in.lua
            1.1529215046068e+18
            1.1529215046068e+18
            true





            share|improve this answer





























              10














              Lua 5.3 as used in texlive 2019 luatex has a (64bit) integer type.



              You need to decide what outcome you want, and whether to use the integer or floating point 64bit types.



              The file



              a=1024*1024*1024*1024*1024*1024*1024 -- 2^70
              print(a)


              which is trying to get the integer 2^70



              produces 0 with luatex 1.10 and greater:



              $ texlua in1.lua
              0


              but with older luatex produced an approximate result:



              $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in1.lua
              1.1805916207174e+21


              So you might be tempted to fix this by casting do double, eg this version with 1.0



              a=1.0*1024*1024*1024*1024*1024*1024*1024 -- 2^70
              print(a)


              Produces 1.1805916207174e+21 on both systems.



              Note however double requires some bits to store the exponent so while it will not overflow at 2^64 it can not accurately store integers above 2^56



              Compare this file that calculates 2^60 then adds 1.



              a=1024*1024*1024*1024*1024*1024
              print(a)
              b=a+1
              print(b)
              print (a == b)


              This works in exact integer arithmetic with Lua 5.3



              $ texlua in.lua
              1152921504606846976
              1152921504606846977
              false


              but works in double arithmetic, and a final result of true rather than false, in Lua 5.2.



              $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in.lua
              1.1529215046068e+18
              1.1529215046068e+18
              true





              share|improve this answer



























                10












                10








                10







                Lua 5.3 as used in texlive 2019 luatex has a (64bit) integer type.



                You need to decide what outcome you want, and whether to use the integer or floating point 64bit types.



                The file



                a=1024*1024*1024*1024*1024*1024*1024 -- 2^70
                print(a)


                which is trying to get the integer 2^70



                produces 0 with luatex 1.10 and greater:



                $ texlua in1.lua
                0


                but with older luatex produced an approximate result:



                $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in1.lua
                1.1805916207174e+21


                So you might be tempted to fix this by casting do double, eg this version with 1.0



                a=1.0*1024*1024*1024*1024*1024*1024*1024 -- 2^70
                print(a)


                Produces 1.1805916207174e+21 on both systems.



                Note however double requires some bits to store the exponent so while it will not overflow at 2^64 it can not accurately store integers above 2^56



                Compare this file that calculates 2^60 then adds 1.



                a=1024*1024*1024*1024*1024*1024
                print(a)
                b=a+1
                print(b)
                print (a == b)


                This works in exact integer arithmetic with Lua 5.3



                $ texlua in.lua
                1152921504606846976
                1152921504606846977
                false


                but works in double arithmetic, and a final result of true rather than false, in Lua 5.2.



                $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in.lua
                1.1529215046068e+18
                1.1529215046068e+18
                true





                share|improve this answer













                Lua 5.3 as used in texlive 2019 luatex has a (64bit) integer type.



                You need to decide what outcome you want, and whether to use the integer or floating point 64bit types.



                The file



                a=1024*1024*1024*1024*1024*1024*1024 -- 2^70
                print(a)


                which is trying to get the integer 2^70



                produces 0 with luatex 1.10 and greater:



                $ texlua in1.lua
                0


                but with older luatex produced an approximate result:



                $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in1.lua
                1.1805916207174e+21


                So you might be tempted to fix this by casting do double, eg this version with 1.0



                a=1.0*1024*1024*1024*1024*1024*1024*1024 -- 2^70
                print(a)


                Produces 1.1805916207174e+21 on both systems.



                Note however double requires some bits to store the exponent so while it will not overflow at 2^64 it can not accurately store integers above 2^56



                Compare this file that calculates 2^60 then adds 1.



                a=1024*1024*1024*1024*1024*1024
                print(a)
                b=a+1
                print(b)
                print (a == b)


                This works in exact integer arithmetic with Lua 5.3



                $ texlua in.lua
                1152921504606846976
                1152921504606846977
                false


                but works in double arithmetic, and a final result of true rather than false, in Lua 5.2.



                $ /usr/local/texlive/2018/bin/x86_64-cygwin/texlua in.lua
                1.1529215046068e+18
                1.1529215046068e+18
                true






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 4 at 9:53









                David CarlisleDavid Carlisle

                519k44 gold badges1175 silver badges1945 bronze badges




                519k44 gold badges1175 silver badges1945 bronze badges






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f502742%2fdifferent-answers-of-calculations-in-lualatex-on-local-computer-lua-compiler-an%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form