You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/05/03 19:50:21 UTC

[GitHub] [daffodil] mbeckerle commented on a change in pull request #550: Daffodil-2473 [WIP]

mbeckerle commented on a change in pull request #550:
URL: https://github.com/apache/daffodil/pull/550#discussion_r625323627



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/FNFunctions.scala
##########
@@ -803,6 +803,54 @@ case class FNFloor(recipe: CompiledDPath, argType: NodeInfo.Kind) extends FNOneA
   }
 }
 
+case class DFDLXLeftShift(recipes: List[CompiledDPath],argType: NodeInfo.Kind) extends FNTwoArgs(recipes) {
+  override def computeValue(arg1: DataValuePrimitive, arg2: DataValuePrimitive, dstate: DState) = {
+    val shift = asInt(arg2.getAnyRef).intValue
+    argType match {
+      case NodeInfo.Long => {
+        val leftShift = asLong(arg1).longValue()
+        if (leftShift.toString.length < shift) {

Review comment:
       You don't want the toString length here. You want 64 because a Long is defined to be 64 bits long. 
   Similarly below for the int case you want 32, short 16, byte 8. 
   
   I think the comparison wants to be <=, because if the shift left is 64 or greater, then the answer is 0. 




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org