stevedlawrence commented on a change in pull request #29: Fixed bug in 
calculating bit length for delimited unparsing
URL: https://github.com/apache/incubator-daffodil/pull/29#discussion_r163657169
 
 

 ##########
 File path: 
daffodil-runtime1-unparser/src/main/scala/edu/illinois/ncsa/daffodil/processors/unparsers/BCDUnparsers.scala
 ##########
 @@ -54,7 +54,14 @@ final class BCDIntegerMinLengthInBytesUnparser(
   extends BCDIntegerBaseUnparser(e) {
 
   override def getBitLength(state: ParseOrUnparseState): Int = {
-    val len = 
state.currentNode.get.asSimple.dataValue.asInstanceOf[Array[Byte]].length * 8
+    val bitLen = 
state.currentNode.get.asSimple.dataValue.asInstanceOf[JBigInteger].bitLength
 
 Review comment:
   BigInteger.bitLength returns the length in bits in two's complement. But 
don't we want the length in bits in BCD? Do we need to unparse the BigInteger 
to a byte array first, and if that isn't at least minLength then add some 
padding bits? Or perhaps we pass the minLength into the bcdFromBigInteger() to 
accept a minLength, and the padding logic could be done there if it's easier? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to