'---------------------------------------------------------------------------------------- ' Name: FLOAT_TO_REAL.TIG ' Type: TIGER-BASIC(tm) Source Code ' ' Purpose: Convert a single-precisition float to a double-precisition tiger-basic real ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' ' '---------------------------------------------------------------------------------------- '---------------------------------------------------------------------------------------- ' ' Input: llFloat = single-precisition float (four bytes) ' Output: llReal = double-precisition float (eight bytes) => tiger-basic: real ' '---------------------------------------------------------------------------------------- ' ' Examples for floats: ' ' Single: 0 10000010 01101000000000000000000 ' sign exponent mantissa ' ' Double: 0 10001110100 0000101001000111101011101111111011000101001101001001 ' sign exponent mantissa ' '---------------------------------------------------------------------------------------- SUB Float2Real( long lpFloat; var real rpvReal) long llLow, llHigh ' the low and high four bytes of the new real llHigh = CUT_BITS(lpFloat,23,8) ' get the 8 bits of the exponent llHigh = llHigh + 896 ' readjust the exponents bias-value (single precision: bias = 127; double precision: bias = 1023) if sgn( lpFloat) < 0 then ' add sign bit to the exponent (if necessary) llHigh = llHigh bitor 2048 endif llHigh = (llHigh shl 4) bitor CUT_BITS(lpFloat,19,4) ' shift the exponent up four bits and add the upper 4 bits of the matissa to the exponent llHigh = (llHigh shl 16) bitor CUT_BITS(lpFloat,3,16) ' move up 16 bits and add the next 16 bit of the matissa llLow = CUT_BITS(lpFloat,0,3) shl 29 ' get the low four bits of the matissa and move them up 29 bits rpvReal = LLTOR(llLow,llHigh) ' convert the high- and low-byte-longs to double (tiger REAL-format) END