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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:04:54+00:00 2026-06-13T13:04:54+00:00

What is idiomatic way to convert standard hexadecimal string (like 0x0123) to BigInteger in

  • 0

What is idiomatic way to convert standard hexadecimal string (like “0x0123”) to BigInteger in C#?

What I tried requires removing the hex prefix manually:

using System;
using System.Numerics;
using System.Globalization;

namespace TestHex
{
    class Program
    {
        static void Main(string[] args)
        {
            BigInteger A;
// it does not work
//            A = BigInteger.Parse("0x0123");
// it works, but without hex prefix
            A = BigInteger.Parse("123", NumberStyles.AllowHexSpecifier);
            Console.WriteLine(A);
            Console.ReadLine();
        }
    }
}
  • 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-13T13:04:55+00:00Added an answer on June 13, 2026 at 1:04 pm

    According to the MSDN documentation, the idiom is to only accept hexadecimal strings without 0x as input, but then to lie to the user by outputting them prefixed with 0x:

    public class Example
    {
        public static void Main()
        {
            string[] hexStrings = { "80", "E293", "F9A2FF", "FFFFFFFF", 
                                    "080", "0E293", "0F9A2FF", "0FFFFFFFF",  
                                    "0080", "00E293", "00F9A2FF", "00FFFFFFFF" };
            foreach (string hexString in hexStrings)
            {
                BigInteger number = BigInteger.Parse(
                    hexString,
                    NumberStyles.AllowHexSpecifier);
                Console.WriteLine("Converted 0x{0} to {1}.", hexString, number);
            }         
        }
    }
    // The example displays the following output: 
    //       Converted 0x80 to -128. 
    //       Converted 0xE293 to -7533. 
    //       Converted 0xF9A2FF to -417025. 
    //       Converted 0xFFFFFFFF to -1. 
    //       Converted 0x080 to 128. 
    //       Converted 0x0E293 to 58003. 
    //       Converted 0x0F9A2FF to 16360191. 
    //       Converted 0x0FFFFFFFF to 4294967295. 
    //       Converted 0x0080 to 128. 
    //       Converted 0x00E293 to 58003. 
    //       Converted 0x00F9A2FF to 16360191. 
    //       Converted 0x00FFFFFFFF to 4294967295.
    

    That’s a really rubbish idiom. I’d invent your own idiom that fits your use case.

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

Sidebar

Related Questions

Is there a idiomatic way of removing elements from PATH-like shell variables? That is
What would be the best way and more idiomatic to break a string into
What is the Clojure-idiomatic way to convert a data structure to a Java collection,
What is the idiomatic way to handle exceptions in ring apps. I would like
Given the following string, produced by jsawk : [123,456,789] Is there an idiomatic way
Is this an idiomatic way to convert a Guid to a Guid? ? new
What's the most idiomatic way to convert a set of integers into a set
What is the Ruby idiomatic way for retrieving a single character from a string
What's an idiomatic way of treating a bytestring nibblewise and pretty printing its hexadecimal
What is an idiomatic way to convert a sequence to a set in Clojure?

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.