长整形科学计数转字符串

--long类型的数字转字符串,解决如(2.0190531043722e+15)这种数字转字符串的问题
function Util.LongNumber2String(longNumber)
    local result = ""
    local startAppend = false
    for i = 25, 0, -1 do
        local pow = math.pow(10, i)
        local compare = math.floor(longNumber / pow)
        --print(compare, number, pow)
        if compare == 0 then
            if startAppend then
                result = result .. "0"
            end
        else
            startAppend = true
            result = result .. compare
            longNumber = longNumber - pow * compare
        end
    end
    return result
end

这里是用的lua。

猜你喜欢

转载自blog.csdn.net/cheng219101/article/details/90719962