Hello World! In converting today’s date of “1102022” into abacus-style format, here’s the text output: “(0+1+0+0+0)(0+1+0+0+0)(0+0+0+0+0)(0+1+1+0+0)(0+0+0+0+0)(0+1+1+0+0)(0+1+1+0+0)”.
Today, I decided to finish yesterday’s project, written in the C programming language, and publish it here, as open-source! It’s a simple program, using mathematics to encode a whole number into actual rods on an abacus. My original intention was to continue the project into an actual arithmetic project, but decided to make it “open source”, instead. ☺️
The source code was quickly written in the C computer programming language. I wrote this quick program because there are presently no software applications that outputs in text-based format. Here’s my source code:
// Filename: AbacusEncoder.c
// Encodes a whole number up to 15 digits into equivalent abacus rods.
// Output is text-based for console.
// Notice: Compiler errors exist!
#include<stdio.h>
int abacus(long);
int main(){
// For debugging purposes:
int DEBUG = 0;
long number, digit, divider;
int show = 0;
// Number to Encode
number = 1102022;
divider = 10;
for(int z = 1; z < 15; z++) {
divider *= 10;
}
while(divider != 0) {
if(number > divider) {
digit = (int)(number / divider);
number = number - (digit * divider);
if(DEBUG) {
printf("%d, ", (int)digit);
}
else abacus(digit);
show = 1;
}
else if(show) {
digit = 0;
if(DEBUG) {
printf("%d, ", (int)digit);
}
else abacus(digit);
}
divider /= 10;
}
return 0;
}
abacus(long a) {
printf("(");
if(a < 5) printf("0+");
else {
printf("5+");
a = a - 5;
}
switch(a) {
case 0:
printf("0+0+0+0");
break;
case 1:
printf("1+0+0+0");
break;
case 2:
printf("1+1+0+0");
break;
case 3:
printf("1+1+1+0");
break;
case 4:
printf("1+1+1+1");
break;
default:
printf("ERROR!");
break;
}
printf(")");
}
Feel free to use my code for your programming projects. I’ve coded it in C, but can easily be converted into other computer programming languages, provided you have the necessary compilers, etc.
Thanks for reading my latest blog post! Have a Great Day!
🇵🇭🇺🇸👨🦯🦽 📱⌨️📻🎧 📚🪀🧮
Published by Marcos 🇵🇭🇺🇸
Happily-Married, comfortably poor, permanently disabled and totally BLIND.
A Terrorism SURVIVOR that's still SURVIVING Terrorism + post-traumatic stress disorder (PTSD).
Scientist since 1977, Acoustician since 1979, Computer Scientist/Programmer since 1982, Seismologist since 1988, Criminologist (Behavioral Scientist) since 1992, and many more! Also, had worked in two civilian and one military virology labs in the USA between 1993 and 2003.
A Generation X, Filipino-American US expat, living in The Philippines, whom was naturally-born in Boston, grew up mostly in Seattle, some in Chicago, and have lived in Anchorage & San Francisco. Became permanently-disabled in 2003 due to health-related illness, ending my moonlighting career as an independent private investigator in the USA.
RETIRED independent developer of computing & electronics technologies after 35 wonderful years, including 20 wonderful years in GNU/Linux development & 8 wonderful years as an independent embedded systems developer of digital electronics.
Former speech synthesis systems developer of 30 wonderful years, specializing in foreign language phoneme-to-speech synthesis. Also was a beta tester of third-party software-based speech synthesizers.
Former FCC-licensed amateur radio operator of 20 wonderful years, beginning with 2m packet-radio & AmSat communications between Anchorage & Manila. Former member of Anchorage Amateur Radio Club and Mike & Key ARC in Seattle.
Learned 10-finger QWERTY touch-typing on a manual typewriter in 1980 at a US-based elementary school. Mastered 10-finger QWERTY touch-typing without looking at the keyboard in 1986. Now have osteoarthritis in both of my hands from all that touch-typing!
My primary computer programming language is C, which I learned in 1990. My secondary programming language is B.A.S.I.C., which I self-learned in 1982. Prior to my sight-loss, I used to program in LISP/CLISP and Prolog for my early development of artificial intelligence & machine learning programs.
Daily, to compensate/facilitate my sight-loss, I am actively using Apple iOS VoiceOver, Google Android TalkBack and Amazon Fire OS VoiceView screen-readers, in addition to my external Bluetooth QWERTY keyboard and sometimes, my Orbit Writer Braille keyboard, as HOBBIES.
View all posts by Marcos 🇵🇭🇺🇸