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 9206711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:14:00+00:00 2026-06-18T00:14:00+00:00

I want to print a padded to 32 bits word in binary in Racket.

  • 0

I want to print a padded to 32 bits word in binary in Racket. I know about printf and “~b”, but I want it padded to be 32 bits long each time. How do I do this?

Example

(printf "~b" 42) 
=> 101010
Want: 00000000000000000000000000101010
  • 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-06-18T00:14:01+00:00Added an answer on June 18, 2026 at 12:14 am

    Here’s a concise way to do it with Racket 5.3.1 and above:

    Welcome to Racket v5.3.2.3.
    -> (require racket/format)
    -> (~r 42 #:base 2 #:min-width 32 #:pad-string "0")
    "00000000000000000000000000101010"
    

    See racket/format for more details.

    In older Racket versions, you can do this:

    Welcome to Racket v5.3.
    -> (require srfi/13)
    -> (string-pad (number->string 42 2) 32 #\0)
    "00000000000000000000000000101010"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to print next line of matching word with sed. I tried this
I want to print the execution time taken for each individual Ant target and
I want to print an integer number in binary mode using following function: #include
I want to print the ID of the comment (eg. 10151828637085391_33268745 ) from this
I want to print all the prime numbers between two numbers. This is my
i want print it in this format: ex. 1 -> 000001 15 -> 000015
I want to print a specific NSView. When I do this, I wish to
I want print div content with style(separate .css file). I tried much but unable
For example if i want print indexes of this objects: items = Item.objects.filter(depth=1) How
For example. I want to print numbers from 1 to 20 but I want

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.