Loading ...
Sorry, an error occurred while loading the content.

Re: integer == character

Expand Messages
  • Benji Fisher
    I cannot answer why; with a little thought, anyone can come up with situations where one or the other behavior is more convenient. There is also the question
    Message 1 of 5 , Dec 31, 2002
    • 0 Attachment
      I cannot answer why; with a little thought, anyone can come up
      with situations where one or the other behavior is more convenient.
      There is also the question of how to convert "xyz" to a number: should
      vim include support for arbitrary-precision arithmetic? (I think not.)

      If you do want to convert a single-character string to its ASCII
      value, you can use the built-in function char2nr().

      :help char2nr()

      HTH --Benji Fisher

      vipin aravind wrote:
      > Why is 'x' 0 ?
      > Why can't it become the ascii value?
      > or probably the syntax parser can fail for those cases
      > vipin
      >
      > -----Original Message-----
      > From: Bram Moolenaar [mailto:Bram@...]
      > Sent: Tuesday, December 31, 2002 2:39 PM
      > To: Charles E. Campbell
      > Cc: VimDev
      > Subject: Re: integer == character
      >
      > Although this is unexpected, it is correct. From the help:
      >
      > When comparing a String with a Number, the String is converted
      > to a Number, and the comparison is done on Numbers.
      >
      > To avoid confusion I'll add this remark:
      >
      > This means that "0 == 'x'" is TRUE, because 'x' converted to a
      > Number is zero.
    Your message has been successfully submitted and would be delivered to recipients shortly.