On Thu, Apr 1, 2010 at 12:29 AM, Armando Blancas
wrote:
> But if numbers should default to positive but not be coerced to
> negative, e.g., a -189 just for (short -0xBD) this might work, using
> nil for out of range values:
Yeah, but I was assuming (insert standard caveat here) that the goal
is t
> The full, future-proof solution is something like this:
>
> (map #(let [n (Integer/parseInt % 16)] (short (if (bit-test n 15)
> (bit-or n -65536) (bit-and n 65535 ["ff43" "0032"])
(-189 50)
But if numbers should default to positive but not be coerced to
negative, e.g., a -189 just for (shor
On Wednesday, March 31, 2010, Richard Newman wrote:
>
> ur=> (map #(Integer/parseInt % 16) ["ff43" "0032"])
> (65347 50)
>
>
> ...that yields ints, not shorts.
>
>
> At the risk of diverging from the question: why are you concerned with the
> specific type of the number?
I am because the OP was.
ur=> (map #(Integer/parseInt % 16) ["ff43" "0032"])
(65347 50)
...that yields, not shorts.
At the risk of diverging from the question: why are you concerned with
the specific type of the number?
You realize that Java doesn't allocate less memory for a short than
for an int, right? The on
On Wed, Mar 31, 2010 at 7:22 PM, Glen Rubin wrote:
> I have a sequence of hex strings, e.g.
>
> "ff43" "0032" ... (you get the idea)
>
> I want to use clojure's short form on them, but short expects an
> authentic hex input, e.g.
>
> (short 0xff43)
>
> it will not accept something like (short "0xf
"ff43" "0032" ... (you get the idea)
I want to use clojure's short form on them, but short expects an
authentic hex input, e.g.
(short 0xff43)
it will not accept something like (short "0xff43")
Any suggestions would be gratefully appreciated!!
user=> (map #(Integer/parseInt % 16) ["ff43" "00
I have a sequence of hex strings, e.g.
"ff43" "0032" ... (you get the idea)
I want to use clojure's short form on them, but short expects an
authentic hex input, e.g.
(short 0xff43)
it will not accept something like (short "0xff43")
Any suggestions would be gratefully appreciated!!
--
You re