Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6977843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:40:38+00:00 2026-05-27T17:40:38+00:00

I’m attempting to write an image processing library in Clojure, but I’ve run into

  • 0

I’m attempting to write an image processing library in Clojure, but I’ve run into a problem while writing my tests.

The image data is stored as a 2D array of integers, which are signed (Java, and by extension Clojure, doesn’t have unsigned integers). I have a function to get a pixel at a given pair of coordinates. My test of that function looks something like this:

(is (= (get-pixel image 0 (dec width)) 0xFFFF0000))

That is, see if the pixel at (0, width-1) is red. The problem is, get-pixel returns a signed int, but Clojure treats 0xFFFF0000 as a long. In this case, get pixel is returning -65536 (0xFFFF0000 in hex), and Clojure is checking if it’s equal to 4294901760.

Now, I have a few options. I could rewrite the test using the signed integer interpretation of the hex as a decimal (-65536), but I think that makes the intent of the test less clear. I could write a function to convert the negative number into a positive long, but that’s an added layer of complexity. The simplest way is probably just to do a bitwise and between the two numbers and see if it’s changed, but that still seems more complicated than it should be.

Is there any built-in way to force 0xFFFF0000 to be evaluated as a signed integer rather than a long, or to do a bitwise comparison of two arbitrary numbers? The int function doesn’t work, as the number is too large to be represented as a signed int.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:40:39+00:00Added an answer on May 27, 2026 at 5:40 pm

    In clojure 1.3, there’s an unchecked-int function, which just takes the bottom four bytes and makes them an int:

    user> (unchecked-int 0xffff0000)
    -65536
    

    It’s a bit sad that Clojure doesn’t let you enter literal numbers of different sizes – here we’re doing the equivalent of the Java (int)0xffff0000L.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.