Search code examples
vimfloating-pointnumbersintegerexponential

How can I resolve these problems with numbers?


I still have troubles with numbers in Vim:

p.e.

let a = 1.02 | let b = '10000000' | let total = a*b | echo total --> 1.02e7  

I would like to avoid Exponentials. How can I have the output 10200000 ?

let a = 4000000000 | let b = '1' | let total = a+b | echo total  --> -294967295 

Why does this give a wrong output?

Tnx


Solution

  • Using printf:

    let a = 1.02 | let b = '10000000' | let total = a*b | echo printf( "%.f", total)
    

    Output:

    10200000