summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luamaths/luamaths-complex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/luamaths/luamaths-complex.lua')
-rw-r--r--macros/luatex/latex/luamaths/luamaths-complex.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/macros/luatex/latex/luamaths/luamaths-complex.lua b/macros/luatex/latex/luamaths/luamaths-complex.lua
index 68fd055b5e..d8ad289d3f 100644
--- a/macros/luatex/latex/luamaths/luamaths-complex.lua
+++ b/macros/luatex/latex/luamaths/luamaths-complex.lua
@@ -1,7 +1,7 @@
---Version=1.3, Date=30-July-2023
+--Version=1.4, Date=04-Aug-2023
-- provides module for complex numbers
--Contains a modified version of the file complex.lua. It is availalbe on the link https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua. This is licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
---Licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
+--This file is also licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
frac= require("luamaths-fractions")
complex = {}
@@ -107,6 +107,12 @@ function complex.tostring( cx,formatstr )
imunit = "\\imUnit"
local real,imag = cx[1],cx[2]
if type(cx[1]) ~= "table" and type(cx[2]) ~= "table" then
+ if imag == 0 and math.floor(real)==real then
+ return math.floor(real)
+ end
+ if real == 0 and math.floor(imag)==imag and math.abs(math.floor(imag))~=1 then
+ return math.floor(imag)..imunit
+ end
if imag == 0 then
return real
elseif real == 0 then