From 6baf48e0a43df71f282cabacc8dbffc97ad5bb89 Mon Sep 17 00:00:00 2001 From: adash Date: Mon, 20 Apr 2009 23:37:28 +0000 Subject: [PATCH] small changes and support for printing doubles in String class --- .../Benchmarks/SingleTM/KMeans/KMeans.java | 1 - .../src/Benchmarks/SingleTM/KMeans/makefile | 2 +- Robust/src/ClassLibrary/String.java | 55 ++++++++++++++++++- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java b/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java index 209257a8..041db950 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java @@ -214,7 +214,6 @@ public class KMeans extends Thread { * Since zscore transform may perform in cluster() which modifies the * contents of attributes[][], we need to re-store the originals */ - //memcpy(attributes[0], buf, (numObjects * numAttributes * sizeof(double))); for(int x = 0; x < numObjects; x++) { for(int y = 0; y < numAttributes; y++) { attributes[x][y] = buf[x][y]; diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/makefile b/Robust/src/Benchmarks/SingleTM/KMeans/makefile index 0180fbcc..25fe5c20 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/makefile +++ b/Robust/src/Benchmarks/SingleTM/KMeans/makefile @@ -5,7 +5,7 @@ SRC=${MAINCLASS}.java \ Normal.java \ Common.java \ GlobalArgs.java \ - Barrier.java + ../../../ClassLibrary/JavaSTM/Barrier.java FLAGS=-mainclass ${MAINCLASS} -singleTM -nooptimize -debug -dcopts -abcclose -transstats -profile -joptimize default: ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC} diff --git a/Robust/src/ClassLibrary/String.java b/Robust/src/ClassLibrary/String.java index 147a5b96..7076ebe6 100644 --- a/Robust/src/ClassLibrary/String.java +++ b/Robust/src/ClassLibrary/String.java @@ -288,8 +288,59 @@ public class String { return new String(chararray); } - public static String valueOf(double x) { - return valueOf((long)x); + public static String valueOf(double val) { + int i = 0, j = 0, k = 0; + long nodecimal = 0; + double decimal = 1.0d, valueA = 0.0d; + StringBuffer output = new StringBuffer(); + + for(i = 0; decimal != nodecimal; i++) { + long basePower = 1; + for(int x=0; x= 0; j++) { + long basePower = 1; + for(int x=0; x 0; k--) { + if(k == i) //if a decimal point was previously found + { //insert it where its meant to be + output.append((char)46); + } + long basePower = 1; + for(int x=0; x<(k-1); x++) { + basePower*= 10; + } + nodecimal = ((long) (valueA - decimal) / basePower); + decimal += nodecimal*basePower; + output.append((char)(48 + nodecimal)); + } + + return output.toString(); + } + + public static long basePower(int x, int y) { + long t = 1; + for(int i=0; i