---
# System prepended metadata

title: '[Ruby On Rails][ruby]無條件進位'
tags: [Ruby On Rails]

---

# [Ruby On Rails][ruby]無條件進位

###### tags: `Ruby On Rails`

以下為在terminal使用irb的紀錄:
```terminal
twkhjl@ubuntu:~$ irb
2.2.6 :001 > cnt=66
 => 66 
2.2.6 :002 > cnt=64
 => 64 
2.2.6 :003 > (64/6).ceil
 => 10 
2.2.6 :004 > 64/6
 => 10 
2.2.6 :005 > 64.0/6
 => 10.666666666666666 
2.2.6 :006 > (64.0/6).ceil
 => 11 

```

從中可以發現,只要先把整數轉為浮點數再配合ceil即可無條件進位:


```ruby
a=64
b=6

#to_f可把值轉為浮點數(float)
p (a.to_f/b).ceil
```




