Convert an Character to the ASCII Character Code

Discussion in 'Ruby' started by John Gregory, Jul 5, 2009.

  1. John Gregory

    John Gregory Guest

    I have Ruby 1.9.1p129 and I want to convert an ASCII character to an
    Integer and a Float.

    While reading the following web page, I found conflicts in the code
    usage:

    'Convert an Character to the ASCII Character Code'

    Integer (?e)
    => 101

    (then further down)

    Float (?e)
    => 101.0

    I received errors as per the attached screen snapshot.

    I have found out that it is because I have version 1.9 and the above was
    only workable in version 1.8.

    I would still like to know how to get the same results using my current
    version.

    Thanks.

    Attachments:
    http://www.ruby-forum.com/attachment/3867/convert_error.jpeg

    --
    Posted via http://www.ruby-forum.com/.
     
    John Gregory, Jul 5, 2009
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    1
    Views:
    7,203
    Bruce Barker
    Mar 15, 2006
  2. Replies:
    16
    Views:
    2,559
    Dave Thompson
    Mar 3, 2006
  3. jt
    Replies:
    2
    Views:
    1,324
    upashu2
    Jul 14, 2005
  4. Tomás Ó hÉilidhe

    Convert native character string to ASCII array of integers

    Tomás Ó hÉilidhe, Mar 28, 2008, in forum: C Programming
    Replies:
    56
    Views:
    3,424
    CBFalconer
    Mar 31, 2008
  5. Xianwen Chen

    Convert an integer value to ASCII character

    Xianwen Chen, Feb 13, 2011, in forum: C Programming
    Replies:
    9
    Views:
    6,206
    alphareaper
    Oct 31, 2012
  6. Alextophi
    Replies:
    8
    Views:
    872
    Alan J. Flavell
    Dec 30, 2005
  7. Replies:
    1
    Views:
    201
    Evertjan.
    May 4, 2007
  8. bruce
    Replies:
    38
    Views:
    664
    Mark Lawrence
    Nov 1, 2013
Loading...