资源加载中... loading...

_N

Format a floating point number.

The formatted floating point number according to the precision setting. number

_N() _N(num) _N(num, precision)

The floating point number that needs to be formatted. num true number The precision setting for formatting, the parameter precision is an integer, and the parameter precision defaults to 4. precision false number

function main(){
    var i = 3.1415
    Log(i)
    var ii = _N(i, 2)
    Log(ii)
}
def main():
    i = 3.1415
    Log(i)
    ii = _N(i, 2)
    Log(ii)
void main() {
    auto i = 3.1415;
    Log(i);
    auto ii = _N(i, 2);
    Log(ii);
}

For example, _N(3.1415, 2) will delete the value after 3.1415 two decimal places and the function returns 3.14.

function main(){
    var i = 1300
    Log(i)
    var ii = _N(i, -3)
    // Check the logs and see that it is 1000
    Log(ii)
}
def main():
    i = 1300
    Log(i)
    ii = _N(i, -3)
    Log(ii)
void main() {
    auto i = 1300;
    Log(i);
    auto ii = _N(i, -3);
    Log(ii);
}

If you need to change all the N digits to the left of the decimal point to 0, you can write it like this:

The parameter precision can be a positive integer, negative integer.

{@fun/Trade/exchange.SetPrecision exchange.SetPrecision}

_D _C