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

  • Home
  • SEARCH
  • 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 523371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:27:19+00:00 2026-05-13T08:27:19+00:00

the below code print the biginteger to a file in decimal format ,how do

  • 0

the below code print the biginteger to a file in decimal format ,how do i convert the code into printing binary data and hex data into the File instead ??

static void
print_pos( FILE* f, bigint bi )
{
    if ( bi_compare( bi_copy( bi ), bi_10 ) >= 0 )
        print_pos( f, bi_int_divide( bi_copy( bi ), 10 ) );
    putc( bi_int_mod( bi, 10 ) + '0', f );
}

bi_10 is just a type of bigint , how do i modify the above code to print the hex / binary data instead of decimal data ?

  • 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-13T08:27:19+00:00Added an answer on May 13, 2026 at 8:27 am

    To print in base N, you need to make three changes:

    1. Instead of dividing by 10 the in the second line, divide by N
    2. Instead of doing mod 10 in the third line, do mod base N
    3. You will need to convert the the module from line 2 into the appropriate character. If you are doing base > 10, you will need to do an if/else

    Here’s what it would look like using plain integers. I’ll let you make the appropriate changes to use your big int library:

    static void
    print_pos( FILE* f, int n, int base )
    {
        if (n < 0)
        {
            n *= -1;
            putc( '-', f );
        }
    
        if (n >= base)
            print_pos( f, n / base, base );
    
        int d = n % base;
        const char *digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        putc( digits[d], f );
    }
    

    A couple of last comments.

    1. Your original code forget to deal with negative numbers.
    2. This function works up to base 36. If you want even larger bases, you’ll need to extend the char c = ... line.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Not directly, cookies that come directly from the server must… May 13, 2026 at 5:58 pm
  • Editorial Team
    Editorial Team added an answer The first type of construction is not actually constructing the… May 13, 2026 at 5:58 pm
  • Editorial Team
    Editorial Team added an answer To detect an orientation change on an Android browser, attach… May 13, 2026 at 5:58 pm

Related Questions

I have an array of array like below with all numeric values. I want
I was trying to create a pseudo super struct to print array of structs.
I am using the code below to print from an array but its printing
In the code below, $row['site'] is an URL. In Chrome and IE8, it displays
Lets say that I'm trying to solve a parsing problem of string to char

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.