mbeckerle commented on code in PR #1090:
URL: https://github.com/apache/daffodil/pull/1090#discussion_r1345017904


##########
daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/XMLUtils.scala:
##########
@@ -70,6 +70,34 @@ object XMLUtils {
   val NegativeInfinityString = "-INF"
   val NaNString = "NaN"
 
+  /**
+   * Converts a string to a float, including handling our INF, -INF, and NaN 
notations.
+   * @param s
+   * @return
+   */
+  def strToFloat(s: String): Float = {
+    s match {
+      case PositiveInfinityString => Float.PositiveInfinity
+      case NegativeInfinityString => Float.NegativeInfinity
+      case NaNString => Float.NaN
+      case _ => s.toFloat
+    }
+  }
+
+  /**
+   * Converts a string to a double, including handling our INF, -INF, and NaN 
notations.
+   * @param s
+   * @return
+   */
+  def strToDouble(s: String): Double = {
+    s match {
+      case PositiveInfinityString => Double.PositiveInfinity
+      case NegativeInfinityString => Double.NegativeInfinity
+      case NaNString => Double.NaN
+      case _ => s.toDouble
+    }
+  }
+

Review Comment:
   Actually NodeInfo is in daffodil-runtime1, and this is in daffodil-lib, so 
to avoid code duplication I can convert NodeInfo.Double.fromString to call 
this. That's the right thing because the NodeInfo things construct JDouble 
boxed things anyway. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to