Conversion to Binary and IEEE754 Binary

08022020, 02:51 PM
(This post was last modified: 08022020 02:52 PM by Eddie W. Shore.)
Post: #5




RE: Conversion to Binary and IEEE754 Binary
Here is my second attempt at it, except I just concentrated at the conversion to binary, with a usergiven precision level.
To help with rounding the number, I first round the number to the nearest 1/2^n, then convert the result to binary. I have not retried the IEEE754 yet. The program RBIN converts any real number in base 10 to base 2, including nonintegers and negative numbers. The result is displayed as a string. RBIN will need two arguments: the number to be converted and the precision level. For the precision level: 1 rounds the number to the nearest 1/2 before conversion. 2 rounds the number to the nearest 1/4 before conversion. 3 rounds the number to the nearest 1/8 before conversion. 4 rounds the number to the nearest 1/16 before conversion. and so on. HP Prime Program: RBIN Code: EXPORT RBIN(x,p) Examples: RBIN(0.985,3) returns "1" RBIN(0.985,6) returns ".111111" RBIN(0.985,9) returns ".111111000" RBIN(860.63,3) returns "1101011100.101" RBIN(860.63,6) returns "1101011100.101000" RBIN(860.63,9) returns "1101011100.101000011" Link: http://edspi31415.blogspot.com/2020/08/h...sions.html 

« Next Oldest  Next Newest »

Messages In This Thread 
Conversion to Binary and IEEE754 Binary  Eddie W. Shore  06272020, 01:35 PM
RE: Conversion to Binary and IEEE754 Binary  Albert Chan  06272020, 08:37 PM
RE: Conversion to Binary and IEEE754 Binary  Albert Chan  06292020, 01:33 PM
RE: Conversion to Binary and IEEE754 Binary  Eddie W. Shore  06292020, 01:58 PM
RE: Conversion to Binary and IEEE754 Binary  Eddie W. Shore  08022020 02:51 PM

User(s) browsing this thread: 1 Guest(s)