2018年11月25日(日) 14:51 <vstenbock@gmail.com>:
>
> str2float('0x1') returns 1 ( as expected )
> but
> str2float('0b1') returns 0 ( why ? )
If you want to convert strings of hexadecimal (0xa), octal (0755),
binary (0b11110000) to integers, you can use unary + operator.
:echo +'0xa'
=> 10
:echo +'0755'
=> 493
:echo +'0b11110000'
=> 240
P.S.
Vim script can treat an exponential notation, but unary + operator can
not convert it.
:echo 1.0e3
=> 1000.0
:echo +'1.0e3'
=> 1
>
> --
> --
> 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 this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
Takuya Fujiwara
--
--
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 this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment