ccc_ldo@waikato.ac.nz (02/20/90)
In <2977@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon Watte) writes >Try changing half of the longs you use to shorts, randomly, >and see how long your program copes. One minute ? Two minutes ? Looking back over my programs, most (but not all) of my integers are in fact short integers. They *have* been known to run for longer than two minutes... Of course, the fact that most of my programs are in Pascal may have something to do with it. >assigning a long to an inte is _never_ a good practise - >and in this case, it happens to work on MPW C 3 but not earlier >or other Mac compilers. (Work == give the desired effect) What *is* the desired effect? Preserve the value, "pinning" it to the maximum or minimum of the smaller range? Preserve the value modulo 65536? Preserve an arbitrary sixteen bits? Refuse to do the conversion? If the number that the user has typed in is supposed to fit into a short integer, you haven't much choice about doing the conversion, since the Mac only provides a string-to-longint scanner.