-3

I am trying to perform arithmetic using only 16-bit signed words. I need to be able to perform addition, multiplication, etc.

As an example I need to subtract two data values, below is an example: 7269.554688-46.8 or 4385.6616210938 + 32.2

However, these values need to be converted into 16-bit words and then the subtraction, multiplication, or addition can be performed.

I could also use multiple 16-bit words to store one value.

How would I go about performing operations like addition, subtraction and multiplication and how would I convert all of my input values appropriately so that the decimal points always line up properly?

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
Veridian
  • 3,531
  • 12
  • 46
  • 80
  • 2
    The question is too wide open to answer adequately on stackoverflow. You can get Knuth's Seminumerical Algorithms or other texts and see how to implement integer, fixed, and floating point arithmetic using multiple words. – President James K. Polk Jan 11 '12 at 01:15
  • 2
    duplicate of [How to implement floating point using 16 bit words](http://stackoverflow.com/questions/8811977/how-to-implement-floating-point-using-16-bit-words). Edit your original question if it needs clarification; don't just post a new question asking the same thing. – user57368 Jan 11 '12 at 03:14

1 Answers1

1

What platform are you coding for? To perform the operations you've given as an example, you would need a floating point unit. Floating point numbers are usually represented through 32 bits or 64 bits, rarely 16 bit.

If you don't have one and all you have are simple operations on 16 bit integers, you could emulate a floating point unit, but that is not a trivial task.

shapecatcher
  • 907
  • 6
  • 9
  • I am coding for a multicore platform that I have to code for in assembly. So there is no floating point unit. I know this is not trivial, but I thought perhaps there would be some literature on the topic. – Veridian Jan 10 '12 at 23:05