non-working implementation of float and double.toString()

This commit is contained in:
Eric Scharff 2007-10-02 08:58:35 -06:00
parent 45dc118ab9
commit 243d62a952
3 changed files with 22 additions and 1 deletions

View File

@ -69,3 +69,10 @@ Java_java_lang_System_doMapLibraryName(JNIEnv* e, jclass, jstring name)
}
return r;
}
extern "C" JNIEXPORT jint JNICALL
Java_java_lang_Double_fillBufferWithDouble(JNIEnv *e, jclass me, jdouble val,
jbyteArray buffer, jint bufferSize) {
if (e or me or val or buffer or bufferSize) return 0;
return 0;
}

View File

@ -35,7 +35,9 @@ public final class Double extends Number {
}
public static String toString(double v) {
return "Double.toString: todo";
byte[] buffer = new byte[20];
int numChars = fillBufferWithDouble(v, buffer, 20);
return new String(buffer, 0, numChars, false);
}
public byte byteValue() {
@ -67,6 +69,9 @@ public final class Double extends Number {
throw new NumberFormatException(s);
}
public static native int fillBufferWithDouble(double value, byte[] buffer,
int charCount);
public static native long doubleToRawLongBits(double value);
public static native double longBitsToDouble(long bits);

View File

@ -81,6 +81,15 @@ public class StringBuilder {
return append(String.valueOf(v));
}
public StringBuilder append(float v) {
return append(String.valueOf(v));
}
public StringBuilder append(double v) {
return append(String.valueOf(v));
}
public char charAt(int i) {
if (i < 0 || i >= length) {
throw new IndexOutOfBoundsException();