Am 26.11.2018 um 14:38 schrieb Vladimir Stenbock:
If you want to convert strings of hexadecimal (0xa), octal (0755),
binary (0b) to integers, you can use unary + operator.
:echo +'0xa'
=> 10
:echo +'0755'
=> 493
:echo +'0b'
=> 240
P.S.
Vim script can treat an exponential
> If you want to convert strings of hexadecimal (0xa), octal (0755),
> binary (0b) to integers, you can use unary + operator.
>
> :echo +'0xa'
> => 10
> :echo +'0755'
> => 493
> :echo +'0b'
> => 240
>
> P.S.
> Vim script can treat an exponential notation, but unary + operator
2018年11月25日(日) 14:51 :
>
> str2float('0x1') returns 1 ( as expected )
> but
> str2float('0b1') returns 0 ( why ? )
If you want to convert strings of hexadecimal (0xa), octal (0755),
binary (0b) to integers, you can use unary + operator.
:echo +'0xa'
=> 10
:echo +'0755'
=> 493
:echo
Hexadecimal (not octal) seems to be a special case:
:echo str2float('0x1') str2float('0xff') str2float('010') str2float('0b1')
answers
1.0 255.0 10.0 0.0
while
:echo 0x1 0xff 010 0b1
answers
1 255 8 1
Not yet sure if I'll call it a feature or a bug.
Best regards,
Tony.
On
On Sunday, November 25, 2018 at 8:41:56 AM UTC-5, Wolf wrote:
> See help for str2float() - all
> "text after the number is silently ignored" for the second case.
>
> See help in the Variables section 1.1, under the section for conversion.
> For the first case; octal conversion happened in the
See help for str2float() - all "text after the number is silently ignored"
for the second case.
See help in the Variables section 1.1, under the section for conversion.
For the first case; octal conversion happened in the first case before
applying the str2float().
On Sun, Nov 25, 2018 at 12:51
str2float('0x1') returns 1 ( as expected )
but
str2float('0b1') returns 0 ( why ? )
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received