Show Floats

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Show Floats

Nathan M. Holden
Um... well, I solved my own problem.

It turns out that my 20-30 minutes of searching for a way to \definecolor in
terms of 0-255 instead of 0.0-1.0 were just 5 minutes short of finding out a
way to do it.

This is embarrassing.
Reply | Threaded
Open this post in threaded view
|

Show Floats

David Virebayre
On Fri, Nov 6, 2009 at 6:59 AM, Nathan M. Holden <[hidden email]>wrote:

> Um... well, I solved my own problem.
>
> It turns out that my 20-30 minutes of searching for a way to \definecolor
> in
> terms of 0-255 instead of 0.0-1.0 were just 5 minutes short of finding out
> a
> way to do it.
>
> This is embarrassing.
>

If you have this problem again, you can use printf :

GHCi, version 6.10.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> import Text.Printf
Prelude Text.Printf> let f=0.001
Prelude Text.Printf> f
1.0e-3
Prelude Text.Printf> printf "%5.4f\n" f
0.0010
Prelude Text.Printf>



> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091106/b74b4f83/attachment.html
Reply | Threaded
Open this post in threaded view
|

Show Floats

Johannes Laire
On Fri, Nov 6, 2009 at 9:32 AM, David Virebayre
<[hidden email]> wrote:

> On Fri, Nov 6, 2009 at 6:59 AM, Nathan M. Holden <[hidden email]>
> wrote:
>>
>> Um... well, I solved my own problem.
>>
>> It turns out that my 20-30 minutes of searching for a way to \definecolor
>> in
>> terms of 0-255 instead of 0.0-1.0 were just 5 minutes short of finding out
>> a
>> way to do it.
>>
>> This is embarrassing.
>
> If you have this problem again, you can use printf :
<snip>

There's also Numeric:
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Numeric.html

Prelude> Numeric.showFFloat (Just 4) 0.001 ""
"0.0010"

--
Johannes Laire