# [Haskell-cafe] Binary code

Donald Bruce Stewart dons at cse.unsw.edu.au
Mon Nov 27 22:58:47 EST 2006

```trevion:
> Hello,
>
> First, and forgive me if I'm making unwarranted assumptions, but

Yes, almost certainly this is the case. The same questions were asked on
#haskell at pretty much the same time...

15:54:34 --- join: greg_lundien joined #haskell
15:54:51 <greg_lundien> is there a library function in haskell to convert from decimal to binary??
15:55:19 <sjanssen> @hoogle showIntAtBase
15:55:20 <lambdabot> Numeric.showIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS
15:55:39 <greg_lundien> sjanssen: thanks
15:56:10 <sjanssen> > showIntAtBase 100 (head . show) 2 ""
15:56:11 <lambdabot>  "2"
15:56:30 <sjanssen> > showIntAtBase 2 (head . show) 100 ""
15:56:31 <lambdabot>  "1100100"
15:57:04 <dons> greg_lundien: why do you need to convert to binary?
15:57:23 <kpreid> > showIntAtBase 2 Char.intToDigit 100 ""
15:57:24 <lambdabot>  "1100100"
15:57:42 <greg_lundien> dons: uh... long story? do you know how to do it?
15:58:29 <vincenz> all ints are binary
15:58:37 <greg_lundien> the showIntAtBase thing doesn't work with guys
15:58:45 <vincenz> only with girls?
15:58:47 <greg_lundien> *with hugs, not guys
15:58:50 <greg_lundien> lolz
15:58:54 <dons> :m + Numeric
15:58:56 <Cale> import Numeric
15:58:59 <greg_lundien> oic
15:59:01 <dons> ?hoogle showIntAtBase
15:59:02 <lambdabot> Numeric.showIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS
15:59:36 <greg_lundien> cant import numeric
15:59:44 --- quit: greg_lundien ("Leaving")

-- Don
```