From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Help with type conversion needed
Date: 1996/01/08
Date: 1996-01-08T00:00:00+00:00 [thread overview]
Message-ID: <dewar.821111786@schonberg> (raw)
In-Reply-To: 4cq6ku$l5a@flood.weeg.uiowa.edu
iNathan finally explains::
"Right, and this is why I don't want it to be a noop. If I have a range
of values from -32768 to 32767, and I want to shift that range to 0 to
65535, simply doing a noop is NOT sufficient.. i.e. -32768 maps to 0
and 32767 maps to 65535. -1 should map to 32767, NOT 65535."
In otherwords what he wants to do is not a type conversion at all, in that
the result value is different from the input value.
The algorithm is perfectly trivial
Take your original signed value
Uncheck convert to 16-bit modular
add 32768
that's all there is to it!
You do not need to use a larger type at all. Note that the addition of
32768 in modular arithmetic wraps just as you need it to, that is what
modular arithmetic is all about!
next prev parent reply other threads:[~1996-01-08 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4ckmb7$vo0@flood.weeg.uiowa.edu>
[not found] ` <DKrJpC.9HE.0.-s@inmet.camb.inmet.com>
[not found] ` <4cnivs$m1k@flood.weeg.uiowa.edu>
1996-01-08 0:00 ` Help with type conversion needed Tucker Taft
[not found] ` <dewar.821029372@schonberg>
1996-01-08 0:00 ` Nate Bohlmann
1996-01-08 0:00 ` Robert Dewar [this message]
1996-01-08 0:00 ` Keith Thompson
1996-01-09 0:00 ` Geert Bosch
[not found] ` <dewar.821197198@schonberg>
1996-01-09 0:00 ` Nate Bohlmann
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox