Hello, I need a routine binstr(var val:single;,....) since no such in the rtl exists I decided to write one. Also I wanted to make reverse routine bin2float where the input would be string containing 32 ones and zeroes. But I didn't want to bother with extracting mantissa, exponent, shifting adding dropped zero... One idea is to move entire singlenumber to the buffer (array of four bytes) and then I have values of 4 bytes allready figured so I can convert them to binary or in reverse convert 32 binary digits to 4 bytes and move them back to single. This approach worked until I used this on single numbers without floating part. But when I gave number with floating part it appended some numbers after my number. Following code snippet demonstrates the idea. If someone could point me what I am doing wrong there I would be gratefull. program testsingle; var number:single; buf:array[1..4] of byte; i:byte; begin writeln('enter float number '); readln(number); writeln('you entered: ',number); move(number,buf,sizeof(number)); writeln('memory dump - byte by byte from left to right :'); for i:=1 to 4 do write(buf[i],' '); move(buf,number,sizeof(number)); writeln; writeln('result '); writeln(number:0:6); end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal