[mapguide-users] Expression - format float to decimal with 2 decimal places

Ryan Northcott rnorthcott at gmail.com
Mon Mar 11 07:03:47 PDT 2013


Ahh.. Then that's a Masking,/Padding you want then, and not a Rounding Math
function.

Rounding 12.000 to 12 is correct no matter how many decimal places you ask
for.
12.10000 will probably go to 12.1 as well

I know with a couple steps of logic you could probably use INSTR() and RPAD
to test for whole number/tenths then Rpad in extra zeroes when conditions
hit.
I can't think of any other ideas off the top of my head..

Unless MapGuide parses DataFormat expressions,  something like using
{0:"c"} for Currency, or {0:"n"} for 2 digit Number. {0:"MM/dd/yyyy"} etc.
I've not seen anything like that yet in my travels.

-Ryan



On Mon, Mar 11, 2013 at 9:51 AM, Gunter Becker <gunter.becker at csogis.de>wrote:

> Ryan,
>
> thanks for your reply.
>
> I think you misunderstood my problem. I don't want to strip of the decimal
> places. Instead I do want to have 2 digital places. My problem is that I
> have already a float (ex 30.00000) and the expression engine automatically
> strips of the decimal places. But I would like to have this format: "30.00"
>
> So, I suppose it is a shortcoming of the expression engine.
> Round(property,2) should do the job!
> But if you make a static expression like Round(12.000,2) you will get "12"
> as the result.
>
> Maybe there is a workaround?
>
> Gunter
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/Expression-format-float-to-decimal-with-2-decimal-places-tp5039545p5039596.html
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapguide-users/attachments/20130311/bda09cd2/attachment.html>


More information about the mapguide-users mailing list