[comp.sys.mac.hypercard] REPLY: NumberFormat question

cs2531as@charon.unm.edu (Andrew Stone) (04/22/88)

In article <39648EUA@PSUVM> you write:
>Probably HyperCard provides an easy way to get a two decimals value
>from any number, but I haven't run across it.  I want to get numbers
>to fit neatly in a narrow field, and I need only a couple of decimal
>places.  I imagine quite a few people will want to use this feature
>when dealing with money, but how do I do it?  I want to go from
>numbers like 1.9874578, 3.981635, and 2.762349 to 1.99, 3.92, and
>2.76.  Any ideas?

Easy: use the numberFormat <format string> command:

 example:
          on calculate
        set the numberFormat of field "foo" to "0.00"
        put 5.67898 * 6.89876 into field "foo"
          end calculate

       39.18 will be in field Foo. Use "Put "$" & to get $39.18...


    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |    Andrew Stone     GEnie:ASTONE      505-345-4800        |
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |          "Science is a fable made consistent" - Edward Teller    |
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^