Advertisement
ERROR_CODE

Size

Nov 22nd, 2024 (edited)
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. local text = ""
  2. local byteSize = #text
  3. local kiloByteSize = byteSize / 1024
  4. local megaByteSize = kiloByteSize / 1024
  5. local gigaByteSize = megaByteSize / 1024
  6.  
  7. if byteSize < 1024 then
  8.     print("Вес текста в байтах: " .. byteSize)
  9. elseif kiloByteSize < 1024 then
  10.     print("Вес текста в килобайтах: " .. string.format("%.2f", kiloByteSize))
  11. elseif megaByteSize < 1024 then
  12.     print("Вес текста в мегабайтах: " .. string.format("%.2f", megaByteSize))
  13. else
  14.     print("Вес текста в гигабайтах: " .. string.format("%.2f", gigaByteSize))
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement