[m-rev.] for review: comment in string library Java implementation

James Goddard goddardjames at yahoo.com
Fri Dec 12 15:28:23 AEDT 2003


Estimated hours taken: 0.1
Branches: main

Just added a comment to explain exception handling of Double.parseDouble()

library/string.m:
	Comment appears here:
		string__to_float/2

Index: string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.210
diff -u -d -r1.210 string.m
--- string.m	12 Dec 2003 04:21:16 -0000	1.210
+++ string.m	12 Dec 2003 04:25:29 -0000
@@ -2950,6 +2950,15 @@
 			FloatVal = java.lang.Double.parseDouble(FloatString);
 			succeeded = true;
 		} catch(java.lang.NumberFormatException e) {
+
+			// At this point it *should* in theory be safe just to
+			// set succeeded = false, since the Java API claims
+			// that Double.parseDouble() will handle all the cases
+			// we require.  However, it turns out that in practice
+			// Java actually throws a NumberFormatException when
+			// you give it NaN or infinity, so we handle these
+			// cases below.
+
 			if (FloatString.equalsIgnoreCase(""nan"")) {
 				FloatVal = java.lang.Double.NaN;
 				succeeded = true;
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list