Jump to content
WIK

LUA -> BIG NUMBER

Recommended Posts

Salut, are cineva o idee cum pot face o functie in limbajul LUA prin care sa pot face suma a doua numere mari.

 

Ideea e ca numerele vin in format STRING iar output-ul functiei trebuie sa fie tot string (asta-i cea mai mica problema zic eu) dar am intampinat probleme incercand sa execut functii de genu

 

func('95912101285912112391','55101088101994012311')

 

 

rezultatul este ceva de genu : 5.5101088111585e+019

 

cum as putea sa fac sa pot face suma a acestor doua numere mari ?

Link to comment
Share on other sites

cred ca ai librarie bc disponibila in lua. Uite bc-ul in shell:

tex: ~ $ echo 95912101285912112391+55101088101994012311|bc
151013189387906124702

tex: ~ $ echo 9591210128591211224354656789674564325678391^2|bc
91991311730790638549984859641984226694440749371652476503814301826970940359462364348881

 

edit: te ajuta asta? https://github.com/edubart/lua-bint

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...