When I use this code in a Lua-supporting programming environment, it gives the correct result. However, when I use it in Game Guardian, it does not give the correct result and only provides an integer, not the fraction
Where is the error?
This is the code:
-- هذا مثال تخيلي لحجم الملف بالبايت (عندما يتم تحميله)
local downloadedFileSizeInBytes = 5780000 -- حجم الملف المنزل بالبايت (5.78 ميجابايت)
-- حساب الحجم بالميجابايت والكسر المتبقي
local fileSizeInMB = downloadedFileSizeInBytes / (1000 * 1000)
local remainderInBytes = downloadedFileSizeInBytes % (1000 * 1000)
-- تنسيق الحجم بالميجابايت والكسر للطباعة
local formattedSize = string.format("%.2f MB", fileSizeInMB)
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Question
MahmoudBasem
When I use this code in a Lua-supporting programming environment, it gives the correct result. However, when I use it in Game Guardian, it does not give the correct result and only provides an integer, not the fraction
Where is the error?
This is the code:
-- هذا مثال تخيلي لحجم الملف بالبايت (عندما يتم تحميله)
local downloadedFileSizeInBytes = 5780000 -- حجم الملف المنزل بالبايت (5.78 ميجابايت)
-- حساب الحجم بالميجابايت والكسر المتبقي
local fileSizeInMB = downloadedFileSizeInBytes / (1000 * 1000)
local remainderInBytes = downloadedFileSizeInBytes % (1000 * 1000)
-- تنسيق الحجم بالميجابايت والكسر للطباعة
local formattedSize = string.format("%.2f MB", fileSizeInMB)
print("File Size: " .. formattedSize)
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.