Hey, nice.
+1 for demistifying it.
But it makes no sense.
Let me explain. What _you_ said does make sense.
What _they_ have done with it does not.
The >>/> operators are not supposed to round anything.
They simply have to kick bits to the right, and out of the
picture...
... which incidentally causes a truncation of the input value,
but that is the side-effect, not the driving purpose of the
operator. Let alone taking it 1 step further and proceed to
a rounding according to sign.
I still believe these two operators are simply screwed
(but take this term with a grain of salt -- I better explain
myself at the end)
What would be the usefulness of a rounding up/down that is
to be performed through a bitwise operator (only applicable
to integers, no less) and that can only occur by dividing
by powers of 2?
Get the nonsense of it?
I can hardly identify this as a language intended feature.
Now I too would like to hear someone going official about
such extravagant implement.
But
this is the most official thing I could fetch, and it says
pretty much nothing of interest.
-fox
*** End of the politically correct reply ***
*** Begin of personal thoughts about this matter ***
*** Not a required read, yet could teach something ***
It is clear the devs
deemed appropriate to complied with "reinvent the wheel".
Whether intentional or not.
The >>/> operators exihibit complex function behavior while
they should just be a wrapper to bridge NWscript with the
very CPU RightShift ops, because anyway you look at it that
is the logical thing to do.
And the float datatype is handled internally by custom, flawed
code, instead of relying on the flawless conversion functions
already exposed by the C standard library (which is cross-platform
too, so there is no valid excuse for avoiding its use).
Reinventing the wheel is no professional decision. Never.
It does not smell so Twilight Zone if we understand they could
have done something unwise in the name of cutting the
development times.
Now _that_ is a professional decision, provided they can deal
with its consequences appropriately.
They may have recycled another project and sublimed the
actual NWscript out of it, in the process preserving its
original flaws -- namely: the foul reinventing the wheel,
and its side-effects. Probably they TODO-ed to fix it all
later, but the "go" for it never came (in the end it is not a critical
fault of the software).
Things such as this are done all the time when the project is
big and there is a strict deadline and someone has coughed
millions of real dollars upfront.
Hm.
Has anyone got copy of the book:
The Art of C++
by Herbert Schildt
ISBN:0072255129
McGraw-Hill/Osborne © 2004 ?
At the end of it you find the complete listing of a mini C++
interpreter. Copy, paste, compile -> ready for use.
In its presented form it is raw and unoptimized. But it is
perfectly working, and it can do everything that NWscript
does (save for the UDTs which are not implemented).
Just an example of how cheap it is to recycle a very complex
piece of software that otherwise takes dozens of paid man hours
to develop from scratch.
-fox
Modifié par the.gray.fox, 14 novembre 2011 - 03:27 .