PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Convert 32-bit integer to hexadecimal

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of integer representation, hexadecimal notation, bitwise operations, and 32-bit two's complement arithmetic. It is commonly asked to assess low-level data representation and edge-case handling within the Coding & Algorithms domain, and it tests practical implementation skills alongside conceptual understanding of binary and base conversion.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Convert 32-bit integer to hexadecimal

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem Given a 32-bit signed integer `num`, return its **hexadecimal representation** as a string. ## Requirements - Use **lowercase** letters `a-f`. - Do **not** include leading zeros (unless the value is exactly zero). - For **negative** numbers, return the hexadecimal representation of the corresponding **32-bit two's complement** value. ## Input - Integer `num` in range `[-2^31, 2^31 - 1]` ## Output - A string containing the hexadecimal representation. ## Examples - `num = 26` → `"1a"` - `num = 0` → `"0"` - `num = -1` → `"ffffffff"` ## Follow-ups (optional) - Implement without using built-in base conversion utilities (e.g., no `toString(16)` / `format`).

Quick Answer: This question evaluates understanding of integer representation, hexadecimal notation, bitwise operations, and 32-bit two's complement arithmetic. It is commonly asked to assess low-level data representation and edge-case handling within the Coding & Algorithms domain, and it tests practical implementation skills alongside conceptual understanding of binary and base conversion.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Dec 15, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

Problem

Given a 32-bit signed integer num, return its hexadecimal representation as a string.

Requirements

  • Use lowercase letters a-f .
  • Do not include leading zeros (unless the value is exactly zero).
  • For negative numbers, return the hexadecimal representation of the corresponding 32-bit two's complement value.

Input

  • Integer num in range [-2^31, 2^31 - 1]

Output

  • A string containing the hexadecimal representation.

Examples

  • num = 26 → "1a"
  • num = 0 → "0"
  • num = -1 → "ffffffff"

Follow-ups (optional)

  • Implement without using built-in base conversion utilities (e.g., no toString(16) / format ).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.