class WirisPlugin::ByteBuffer
Public Class Methods
bytesTo32bitsFloat(bytes)
click to toggle source
# File lib/com/wiris/util/type/ByteBuffer.rb, line 51 def self.bytesTo32bitsFloat(bytes) doubleResult = nil returnedArraySize = (bytes::length()/4) doubleResult = [] byteArray = bytes::getData() k = 0 for = 0 returnedArraySize - 1 intResult = ((((byteArray[k + 3]&255) << 24)|((byteArray[k + 2]&255) << 16))|((byteArray[k + 1]&255) << 8))|(byteArray[k]&255) number = TypeTools::intBitsToFloat(intResult) doubleResult[i] = number k += 4 i+=1 end return doubleResult end
bytesTo64bitsFloat(bytes)
click to toggle source
# File lib/com/wiris/util/type/ByteBuffer.rb, line 9 def self.bytesTo64bitsFloat(bytes) doubleResult = nil returnedArraySize = (bytes::length()/8) doubleResult = [] byteArray = bytes::getData() k = 0 for = 0 returnedArraySize - 1 longResult = 0 shift = 0 high = 0 low = 0 shiftAuxiliar = 0 for = 0 8 - 1 longAuxiliar = 0 longAuxiliarHL = 0 longAuxiliar ||=255&byteArray[k] longAuxiliar <<=shift longResult ||=longAuxiliar longAuxiliarHL ||=(255&byteArray[k]) longAuxiliarHL <<=shiftAuxiliar if j < 4 low ||=longAuxiliarHL if j == 3 shiftAuxiliar = -8 end else high ||=longAuxiliarHL end shift += 8 shiftAuxiliar += 8 k+=1 j+=1 end high32 = Int32::ofInt(high) low32 = Int32::ofInt(low) doubleResult[i] = TypeTools::longBitsToDouble(longResult,high32,low32) i+=1 end return doubleResult end
new()
click to toggle source
Calls superclass method
# File lib/com/wiris/util/type/ByteBuffer.rb, line 6 def initialize() super() end