Conflict dividing two integers based on two different architectures

This project focuses on the differences between an int and a long on two different computer architectures.  The size of an int and a long vary from one computer architecture to the other. The variation of the size of an int and a long may cause division calculations to fail.  This is because when the result of a calculation goes over the maximum, a run-time error will be generated. The size of an int is 4 bytes on an IBM.  On an IBM architect, there is no long data type.  This means that on an IBM architecture, the int plays both int and long value for IBM.  On a Windows architecture, the size of an int is 4 bytes and a long is 8 bytes.  int and long are treated as separate data types on a Windows architecture.  Programmers write code this way because they want to manipulate ints and longs to get other ints and longs. A problem with this is that dividing two integers will vary based on the architecture used.  On an IBM machine, the result is truncated and an int is returned.  On a windows architecture, dividing two integers will result in either an int or a double depending on how the two integers were stored. A program that will solve dividing two integers have varying results based on the architecture.  One way of solving this problem is to typecast both integers into a double (or maybe a float).  Also, when dividing two integers, make sure that the second integer is NOT zero when doing the division, and if it is, terminate the program.

The presentation that I mentioned taught about how different architectures (e.g x86 and iSeries) have different ways that datatypes can be manipulated and this can affect the result of the program.  It also taught about the consequences of dividing two integers can have an impact if architecture is not taken into consideration.

Any programming language can write code that can divide two integers correctly relies on whatever architecture it is running on.  Each architecture is different, and this may cause the program to either crash or continue, as long as the same program is run on two different computers with two different architectures.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s