From 3d3b839395123e87bebb63ca6abb05bd0cd58940 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 1 Jul 2003 15:10:04 +0000 Subject: [PATCH] Solve the problem that integers are printed as floats as far as skin parameters and macro return values are concerned. --- src/helma/framework/core/Skin.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/helma/framework/core/Skin.java b/src/helma/framework/core/Skin.java index 1359334b..1f722510 100644 --- a/src/helma/framework/core/Skin.java +++ b/src/helma/framework/core/Skin.java @@ -611,7 +611,19 @@ public final class Skin { return; } } else { - text = value.toString(); + // do not render doubles as doubles unless + // they actually have a decimal place. This is necessary because + // all numbers are handled as Double in JavaScript. + if (value instanceof Double) { + Double d = (Double) value; + if (d.longValue() == d.doubleValue()) { + text = Long.toString(d.longValue()); + } else { + text = d.toString(); + } + } else { + text = value.toString(); + } } if ((text != null) && (text.length() > 0)) {