Conversion to Binary and IEEE-754 Binary
|
08-02-2020, 02:51 PM
(This post was last modified: 08-02-2020 02:52 PM by Eddie W. Shore.)
Post: #5
|
|||
|
|||
RE: Conversion to Binary and IEEE-754 Binary
Here is my second attempt at it, except I just concentrated at the conversion to binary, with a user-given 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 IEEE-754 yet. The program RBIN converts any real number in base 10 to base 2, including non-integers 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 IEEE-754 Binary - Eddie W. Shore - 06-27-2020, 01:35 PM
RE: Conversion to Binary and IEEE-754 Binary - Albert Chan - 06-27-2020, 08:37 PM
RE: Conversion to Binary and IEEE-754 Binary - Albert Chan - 06-29-2020, 01:33 PM
RE: Conversion to Binary and IEEE-754 Binary - Eddie W. Shore - 06-29-2020, 01:58 PM
RE: Conversion to Binary and IEEE-754 Binary - Eddie W. Shore - 08-02-2020 02:51 PM
|
User(s) browsing this thread: 1 Guest(s)