stri ker wrote:
I frequently need to do some basic calculations. I have used the
following within Vim for Integer calculations:
:echo (4+7)*3-14
19
My question is this:
Is there a way to do calculations with doubles instead of integers
without piping to an external program like bc and then inserting into
a buffer?
For example
:r!echo '491.41 - 29.74' | bc
works when putting the result into the buffer.
TIA,
Kevin
Vim knows of no other Numbers than integers, so basically the answer is
no. However, you can of course get the result if you keep track of the
decimal point in your head:
:echo 49141 - 2974
gives 46167 as answer, so you know that 491.41 - 29.74 = 461.67
For multiplication or division it is of course more complicated but not
completely impossible.
Best regards,
Tony.