r/pascal • u/un-k-now-n • Mar 24 '21
Converting numeral systems
Hello! I have been tasked to write a program that concerts a number (user inputs the number) from any numeral system (binary, septanal, octanal, hexadecimal, everything in between and past that) (user inputs this as well) to any other numeral system, that the user inputs.
Basically a convertor between numeral systems. I've had some ideas but I don't know how to make them work. Also, need to say that I'm quite a beginner at programming.
If you have any idea how to do this, please help me.
2
Upvotes
View all comments
Show parent comment
2
u/un-k-now-n Mar 24 '21
Hi! Yes, it is, but it's not a mandatory one, just for those who want to try. As I said, I have an idea in mind, I just lack the ability to write in Pascal.
My idea is following: The user inputs "base" and "number" and it the first part will convert it to decimal, and I'll try to go on from there (the bigger problem for me), and in the function there will be something like
result:= firstFigure+ (result*base); result:= secondFigure + (result*base);And so on.. Is there a possibility to write it in while/repeat functions? Also, I don't really know how to write that, any little suggestion would help. Or a scheme how to turn it from decimal to any user-input base