When dumping out information to (mono-spaced, line-printed) reports, would it get all your numbers to right align? So you get: 1234
9876543
51230 and not 1234
9876543
51230
It's the obvious thing. Dunno about efficiency, wot Tim arsked abaht. But if r-align is your first shot, you need a new name for l-align. I think Tim should benchmark the two ops and see.
The only thing I could think of re: efficiency is that - assuming you can do everything with MOVE and don't need to MOVEL - it strips out a layer of reformating when you dump out the report. Which, thousands of numbers, hundreds of pages, could be a saving when your computing power is measured in how much coal it consumes.
You'd use numeric fields for those though. This is just strings.
You're implying the char*N fields are actually arrays of chars, which though common isn't always the case. Do you know that they are? If they're statically sized, I don't see that there'd be any necessary inherent performance difference.
Do you use fields to store integers or is there a separate type for that? If you had an integer in a field, maybe using the default MOVE behaviour makes it easier to tell if a digit represents tens, hundreds or whatever?
ie what caramel_betty said.
It's a different type for numbers. This is just strings.
It must to be to make things more human-readable without extra processing.
I have a (very) vague recollection that comparing a number to zero is quicker than comparing it anything else.
If that is true, a loop counting down to move the corresponding bytes/characters is theoretically quicker than a loop counting up - i.e. it might be more efficicent to copy from right to left.
Of course, this may well be complete sh!te.
The loop could count down in both cases, you just change the formula for choosing where in the array to stick a character. Where's hoiho? He knows what goes on inside these languages. Tim, are you using an implicit cast from Int to Char here? THAT might make a diff, if you do it with modulo arith, you get the right most chars out first.
Nope, this is all strings.
Could be a big/little-endian thing?
The first thing that occurs to me is filling in zeros. Someone or some application might come along and fill in zeros for the blank spaces. You would want the extra zeros to be on the left rather than the right, so as not to change the values.
Yeah, now I see I totally misunderstood what you were asking. It must be something to do with the architecture of the machines the language was originally designed for.
My guess would be formatting, too - specifically currency amounts to two decimal places so the decimal point lines up.
Could it be that the language designers made the numeric fields move from the right for the reasons the others have mentioned, and then made strings work the same way for consistency, because they thought they might be used as base-(number of characters in character set) numbers, or because they were used to moving from the right and didn't think about it very hard? |