load("stringproc"); decimal(floating) := block([i, digits, vorzeichen, exponent:-127, mantisse:1], if (slength(floating) # 34) then (error("Input String does not have length 34.")), digits: map(parsetoken, charlist(sremove("/", floating))), vorzeichen: (-1)^digits[1], for i:2 thru 9 do exponent: exponent + digits[i]*2^(9-i), for i:10 thru 32 do mantisse: mantisse + digits[i]*2^(9-i), float(vorzeichen * mantisse * 2^exponent) ); tobinarystring(n, len) := block([i, binary:"", digit], for i:len-1 thru 0 step -1 do ( if (n >= 2^i) then (n:n-2^i, digit:"1") else digit:"0", binary: sconc(binary, digit) ), binary ); floating(decimal) := block([i, vorzeichen, e, exponent:"", m, mantisse:""], if (decimal = 0) then error("Null. Not implemented."), if (decimal < 0) then vorzeichen:"1" else vorzeichen:"0", e: floor(log(abs(decimal)) / log(2)), if ((e < -126) or (e > 127)) then error("Out of range."), exponent: tobinarystring(e+127, 8), m: floor((abs(decimal) / 2^e - 1) * 2^23 + 0.5), mantisse: tobinarystring(m, 23), sconc(vorzeichen, "/", exponent, "/", mantisse) );