![]() |
Forum Index : Microcontroller and PC projects : uMITE 5.2 45Chr HEX$ to Decimal$
Author | Message | ||||
redrok![]() Senior Member ![]() Joined: 15/09/2014 Location: United StatesPosts: 209 |
Hi All; Is there an algorithm to convert long HEX strings to Decimal strings and vice verse. My HEX string is 45 characters long. Apparently the Decimal string is 54 or 55 characters long. I want to also convert 135 character Binary but, of course, this is trivial if the HEX conversions work. I've been searching the net but no luck. Of course, if I only had a 16 HEX characters its built into MM. I should say, this is being used in a high precision HEX based "Fixed Point" math calculation. Thanks!!! redrok |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1571 |
Hi Redrok, this is not the answer, but did you see Peter Carnegies "BCD Arithmetic Library"? Maybe a inspiration? Kind regards Michael edit: Perhaps a look in the MMBasic source code helps (Hex$ function)? causality ≠ correlation ≠ coincidence |
||||
redrok![]() Senior Member ![]() Joined: 15/09/2014 Location: United StatesPosts: 209 |
Hi Michael; Yes, I'm aware of Peters "BCD Arithmetic Library" It was the inspiration for me to look at BigNum programs. What made me try to write my own was to use "Fixed Point" arithmetic, numbers with a fractional part. Peters was based on integers. Also it used "Multiply" instructions which are slower than shift and add instructions. I don't know if this is a valid reason yet. When writing my test codes using a single 64bit register, I noticed that I can run the program as though it had a fractional part to the number. What I did so far: 1. Do the standard all integer shift and add routine. > Justify the answer by shifting all the way, 64bits, to the right. 2. Multiply only the fractional part. Left shift The Multiplicand and Multiplier to the left. Then do the shift and add routine. > But DON'T do the Justification shifts for the answer, I.e. 0bits. 3. Same thing but do shift to a more middle position. > Justification of the answer is done to that central position. Note! I haven't figured out how many justification bits are needed yet. I did it by trial and error. I'm sure it can be calculated. Doing it this way I can implement it as a Fixed Point arithimentic unit like this HHHHH.hhhhhhh of any size. I'm now extending the multiply to multiple 64bit registers. BTW, the registers must be 2 times as long as the numbers lengths used. Just as a test I tried to do the Taylor series SIN(x) function. This worked tolerably well with the limited test register size I used. besides, this can be done with only multiplies and constants. ( don't know how to do the divide yet.) BTW, here is an interesting computer math link: Bit Mathematics cookbook Since I don't consider myself a programmer, any help is appreciated. I need to revisit Peters code to see if I can modify it for Fixed Point operation. redrok |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |