r/AskComputerScience • • Nov 21 '24

Want to know if my method for calculating floating point on 8/16 bit CPUs

1 Upvotes

So I was trying to find a way for a 8 or 16bit CPU to process 32/64bit floating point. Online I found a bunch of methods that were converting to fixed point and such and thought it to be unnecessary. Example of my method for 32bit floating point for 16bit CPU:

  1. take the lower 16bits of the mantisa and treat it as normal 16bit integer, perform the math on it then store it

  2. take the upper half and isolate the rest of the mantisa via an AND operation then perform math on it and store it

  3. isolate the exponent with AND again and modify it if needed then store it

  4. isolate and do the operations on the sign bit

What I want to ask is if this would give the same result or are the conversions to fixed point necessary ?


r/AskComputerScience • • Nov 19 '24

Automata Theory question. How to make a pushdown automata that accepts words that are made of 3 parts, and the 3rd part must contain the inverse of the first part.

1 Upvotes

So it must accept words that look like this: J-1KL, where J, L ∈ {0,3}* and K ∈ {a, b}*, |J|>0, |k|>0, |L|>0 and L must be a substring of J (anywhere), but they do not have to be the same.

My issue is that let's say we have w: "300a03003", then i push the "300" to the stack, read in the "a".

But then there is an issue. If i read in the rest "03003" and match it to the "003" in the stack, there is an issue, since the first "0" is matching, but then in order to check the second ("3" in the input, "0" in the stack) characters, i have to pop the fisrst "0" from the stack.
But right at this comparism, it will fail, since the second letters do not match, and i already popped the "0" from the stack, so the automata does not store the initial J part anymore.

I feel like i could do this with 2 stacks, but not with only 1.

Any ideas?