# Integer#ord for 1.8

**URL:** <https://www.ruby-forum.com/t/integer-ord-for-1-8/119819>\
**Category:** Development\
**Created:** [November 10, 2007, 10:20pm UTC](https://www.ruby-forum.com/t/integer-ord-for-1-8/119819 "2007-11-10T22:20:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [November 10, 2007, 10:20pm UTC](https://www.ruby-forum.com/t/integer-ord-for-1-8/119819/1 "2007-11-10T22:20:54Z")

</div>

1.9 e$B$He(B 1.8 e$B$NN\>J}$Ge(B ?a.ord e$B$Ge(B 97  
e$B$,F@$i$l$k$h$&$K!"e(B1.8 e$B$Ke(B  
Integer#ord e$B$r2C$($k$N$O$I$&$G$7$g$&$+!#e(B

# Index: numeric.c

— numeric.c (e$B%j%S%8%g%se(B 13873)  
+++ numeric.c (e$B:n6H%3%T!\<e(B)  
@@ -1807,6 +1807,27 @@  
return rb\_str\_new(&c, 1);  
}

+/\*

- 
  - call-seq:

- 
  - 

```
int.ord => int

```

- 
  - 

- 
  - Returns the int itself.

- 
  - 

- 
  - 

```
65.ord #=> 65

```

- 
  - 

```
?a.ord #=> 97

```

- 
  - 

```
230.ord #=> 230

```

- 
  - 

- 
  - This method is intended for compatibility to

- 
  - character constant in Ruby 1.9.

- \*/
- 

+static VALUE  
+int\_ord(num)

- VALUE num;  
+{
- return num;  
+}
- 

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\*

- Document-class: Fixnum  
@@ -2924,6 +2945,7 @@  
rb\_define\_method(rb\_cInteger, “succ”, int\_succ, 0);  
rb\_define\_method(rb\_cInteger, “next”, int\_succ, 0);  
rb\_define\_method(rb\_cInteger, “chr”, int\_chr, 0);

- rb\_define\_method(rb\_cInteger, “ord”, int\_ord, 0);  
rb\_define\_method(rb\_cInteger, “to\_i”, int\_to\_i, 0);  
rb\_define\_method(rb\_cInteger, “to\_int”, int\_to\_i, 0);  
rb\_define\_method(rb\_cInteger, “floor”, int\_to\_i, 0);

---

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [November 12, 2007, 11:33am UTC](https://www.ruby-forum.com/t/integer-ord-for-1-8/119819/2 "2007-11-12T11:33:53Z")

</div>

At Sun, 11 Nov 2007 06:20:09 +0900,  
Tanaka A. wrote:

> 1.9 ã¨ 1.8 ã®ä¸¡æ–¹ã§ ?a.ord ã§ 97 ãŒå¾—ã‚‰ã‚Œã‚‹ã‚ˆã†ã«ã€1.8 ã«  
> Integer#ord ã‚’åŠ ãˆã‚‹ã®ã¯ã©ã†ã§ã—ã‚‡ã†ã‹ã€‚  
> "  
> String#ord ã‚’è¿½åŠ ã—ã¦ã©ã¡ã‚‰ã§ã‚‚ ‘a’.ord ã¨ã„ã†ã®ã§ã¯ã„ã¾ã„ã¡  
> ã§ã™ã‹ã­ã€‚?a.ord ã¨æ›¸ããŸã„æ°—æŒã¡ã®æ–¹ãŒå¼·ã„ã‹ãªã€‚

–  
/  
/\_\_ \_\_ [Akinori.org](http://Akinori.org) / [MUSHA.org](http://MUSHA.org)  
/ ) ) ) ) / [FreeBSD.org](http://FreeBSD.org) / [Ruby-lang.org](http://Ruby-lang.org)  
Akinori MUSHA aka / (\_ / ( (\_\_( @ [iDaemons.org](http://iDaemons.org) / and.or.jp

“Different eyes see different things,  
Different hearts beat on different strings –  
But there are times for you and me when all such things agree”

---

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [November 12, 2007, 7:43pm UTC](https://www.ruby-forum.com/t/integer-ord-for-1-8/119819/3 "2007-11-12T19:43:48Z")

</div>

At Mon, 12 Nov 2007 23:37:44 +0900,  
Tanaka A. wrote:

> In article [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid),  
> “Akinori MUSHA” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:
> 
> > String#ord ã‚’è¿½åŠ ã—ã¦ã©ã¡ã‚‰ã§ã‚‚ ‘a’.ord ã¨ã„ã†ã®ã§ã¯ã„ã¾ã„ã¡  
> > ã§ã™ã‹ã­ã€‚?a.ord ã¨æ›¸ããŸã„æ°—æŒã¡ã®æ–¹ãŒå¼·ã„ã‹ãªã€‚
> 
> ?a.ord ã®ã‚ˆã†ã« ?a ãŒæ›¸ã„ã¦ã‚ã‚‹ã¨ã“ã‚ã‚’æ›¸ãæ›ãˆã‚‰ã‚Œã‚‹ã®ã§ã‚  
> ã‚Œã°ã„ã„ã®ã§ã™ãŒã€ãƒ©ã‚¤ãƒ–ãƒ©ãƒªã®å‘¼å‡ºå…ƒã« ?a ã¨æ›¸ã„ã¦ã‚ã£ã¦ã€ãƒ©  
> ã‚¤ãƒ–ãƒ©ãƒªå´ã§ãã‚Œã‚’ã‚µãƒãƒ¼ãƒˆã—ãŸã„ã¨ã„ã†ã‚±ãƒ¼ã‚¹ã§ã¯ã†ã¾ãã„ãã¾  
> ã›ã‚“ã€‚

ã€€ãªã‚‹ã»ã©ã€‚äº’æ›æ€§ã®ãŸã‚ã ã‘ã¨ã„ã†ã¨ã“ã‚ãŒå°‘ã—å¼•ã£ã‹ã‹ã£ãŸã‚“  
ã§ã™ãŒã€å°‘ãªãã¨ã‚‚è‡ªç„¶æ•°ãªã‚‰æ„å‘³ã¯é€šã‚‹(ordinal:åºæ•°)ã®ã§ç´å¾—  
ã—ã¾ã—ãŸã€‚

–  
/  
/\_\_ \_\_ [Akinori.org](http://Akinori.org) / [MUSHA.org](http://MUSHA.org)  
/ ) ) ) ) / [FreeBSD.org](http://FreeBSD.org) / [Ruby-lang.org](http://Ruby-lang.org)  
Akinori MUSHA aka / (\_ / ( (\_\_( @ [iDaemons.org](http://iDaemons.org) / and.or.jp

“Different eyes see different things,  
Different hearts beat on different strings –  
But there are times for you and me when all such things agree”

---

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [November 12, 2007, 3:38pm UTC](https://www.ruby-forum.com/t/integer-ord-for-1-8/119819/4 "2007-11-12T15:38:15Z")

</div>

In article [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid),  
“Akinori MUSHA” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> String#ord e$B$rDI2C$7$F$I$A$i$G$be(B ‘a’.ord e$B$H$$$&$N$G$O$$$^$$$Ae(B  
> e$B$G$9$+$M!#e(B?a.ord e$B$H=q$-$?$$5$;}$A$NJ}$,6/$$$+$J!#e(B

?a.ord e$B$N$h$&$Ke(B ?a e$B$,=q$$$F$“$k$H$3$m$r=q$-49$($i$l$k$N$G$“e(B  
e$B$l$P$$$$$N$G$9$,!”%i%$%V%i%j$N8F=P85$Ke(B ?a e$B$H=q$$$F$”$C$F!"%ie(B  
e$B%$%V%i%jB&$G$=$l$r%5%]!\<%H$7$?$$$H$$$&%1!\<%9$G$O$&$^$/$$$-$^e(B  
e$B$;$s!#e(B

e$B8D?ME\*$K$$$($Pe(B abnf e$BFbIt$Ne(B natset (e$B\<+A3?t$N=89ge(B)  
e$B$,$=$&$G!“e(B  
NatSet.new(?\n) e$B$J$I$H=q$-$?$$$H$$$&7P83$,$”$j$^$9!#$^$!!“e(B  
natset e$B$Oe(B abnf e$B$NFbItE\*$J$b$N$H$9$l$P8F=P85$r$9$Y$F=q$-49$(e(B  
e$B$l$P$$$$$H$$$&$N$b$?$7$+$J$s$G$9$,!”\>o$K$=$&$G$-$k$H$$$&$o$1e(B  
e$B$G$b$J$$$G$7$g$&!#e(B

1.8 e$B$G$O@0?t$@$C$?$b$N$,e(B 1.9  
e$B$G$OJ8;zNs$K$J$k$N$G!"$=$N07$$$+$?e(B  
e$B$H$7$F$O!"e(B

1. 1.8 e$B$G$O@0?t$G07$$!"e(B1.9 e$B$G$OJ8;zNs$G07$&e(B
2. 1.8 e$B$G$be(B 1.9 e$B$G$bJ8;zNs$G07$&e(B
3. 1.8 e$B$G$be(B 1.9 e$B$G$b@0?t$G07$&e(B

e$B$H$$$&e(B 3e$B\<o$,9M$($i$l$k$H;W$&$N$G$9$,!"e(B  
e$B:G=i$N$OJQ49%a%=%C%I$OITMW$G!"e(B  
2e$BHVL$N$Oe(B 1.8 e$B$Ne(B Integer#chr e$B$He(B 1.9 e$B$Ne(B  
String#chr e$B$,;H$($F!“e(B  
3e$BHVL$N$Oe(B ord e$B$r;H$$$?$$$,e(B 1.9 e$B$Ke(B String#ord  
e$B$O$”$k$,e(B 1.8 e$B$Ke(B  
Integer#ord e$B$,$J$$!“e(B  
e$B$H$$$&\>u67$G!”$3$N7o$O$=$NH4$1$F$$$ke(B Integer#ord e$B$H$3$m$NDse(B  
e$B0F$J$o$1$G$9!#e(B

e$B$H$$$&$o$1$G$I$&$G$9$+$M!#e(B
