Post Reply 
(11C) (15C) Very fast binary converter + fast modulo
03-03-2024, 09:39 AM
Post: #8
RE: (11C) (15C) Very fast binary converter + fast modulo
This is another program to convert decimals to binary:
Code:
   001 {    44 25 } STO I
   002 {        8 } 8
   003 {       34 } X<=>Y
   004 { 42 21  0 } f LBL 0
   005 {        1 } 1
   006 {        0 } 0
   007 {       34 } X<=>Y
   008 {        2 } 2
   009 {       10 } /
   010 {    43 44 } g INT
   011 {    43 20 } g x==0
   012 {    22  1 } GTO 1
   013 {       33 } Rv
   014 {       20 } *
   015 {       33 } Rv
   016 {       20 } *
   017 { 44 40 25 } STO + I
   018 {       33 } Rv
   019 {    22  0 } GTO 0
   020 { 42 21  1 } f LBL 1
   021 {    45 25 } RCL I

It uses no registers apart from I.
Also it doesn't use MOD but only the INT function.

It's a translation of the following Python program:
Code:
def bin(n):
    s = n
    k = 8
    while n:
        n //= 2
        s += k * n
        k *= 10
    return s

Example

23
R/S

10111.


References
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (11C) (15C) Very fast binary converter + fast modulo - Thomas Klemm - 03-03-2024 09:39 AM



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