# Noob question: How to do number formatting?

**URL:** <https://rubytalk.org/t/noob-question-how-to-do-number-formatting/30193>\
**Category:** ruby-talk\
**Created:** [21 August 2006 21:27 UTC](https://rubytalk.org/t/noob-question-how-to-do-number-formatting/30193 "2006-08-21T21:27:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Johnson2](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Ben\_Johnson2](https://rubytalk.org/u/Ben_Johnson2)\
**Post date:** [21 August 2006 21:27 UTC](https://rubytalk.org/t/noob-question-how-to-do-number-formatting/30193/1 "2006-08-21T21:27:52Z")

</div>

I searched the documentation and everything and can't find a simple  
method for number formatting. Any links?

thanks for your help.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Tim\_Hunter4](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@Tim\_Hunter4](https://rubytalk.org/u/Tim_Hunter4)\
**Post date:** [21 August 2006 21:31 UTC](https://rubytalk.org/t/noob-question-how-to-do-number-formatting/30193/2 "2006-08-21T21:31:42Z")

</div>

Ben Johnson wrote:

> I searched the documentation and everything and can't find a simple method for number formatting. Any links?
> 
> thanks for your help.

Use ri to look up printf, sprintf, and String#%

---

<div class="post-metadata">

**Author:** ![Chris\_Gehlker](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@Chris\_Gehlker](https://rubytalk.org/u/Chris_Gehlker)\
**Post date:** [21 August 2006 21:37 UTC](https://rubytalk.org/t/noob-question-how-to-do-number-formatting/30193/3 "2006-08-21T21:37:54Z")

</div>

Do you know how C formatting works? The Ruby printf methods work the same way. The details are given with:  
ri Kernel#sprintf

> **···**
>
> On Aug 21, 2006, at 2:27 PM, Ben Johnson wrote:
> 
> > I searched the documentation and everything and can't find a simple  
> > method for number formatting. Any links?
> 
> --  
> Conscience is thoroughly well-bred and soon leaves off talking to those who do not wish to hear it.  
> -Samuel Butler, writer (1835-1902)

---

<div class="post-metadata">

**Author:** ![Thorsten\_Haude](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@Thorsten\_Haude](https://rubytalk.org/u/Thorsten_Haude)\
**Post date:** [21 August 2006 21:42 UTC](https://rubytalk.org/t/noob-question-how-to-do-number-formatting/30193/4 "2006-08-21T21:42:08Z")

</div>

Hi,

\* Ben Johnson wrote (2006-08-22 06:27):

> I searched the documentation and everything and can't find a simple  
> method for number formatting. Any links?

Something like this?

&nbsp;&nbsp;&nbsp;&nbsp;[http://www.rubycentral.com/ref/ref\_m\_kernel.html#sprintf](http://www.rubycentral.com/ref/ref_m_kernel.html#sprintf)

Thorsten Broken Social Scene: It's all gonna break

> **···**
>
> --  
> Endorsing products is the American way of expressing individuality.  
> &nbsp;&nbsp;&nbsp;&nbsp;- Calvin
