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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:59:17+00:00 2026-06-02T02:59:17+00:00

Take int x = 5; float y = x; //I know it’s a float

  • 0

Take

int x = 5;
float y = x;

//"I know it's a float .. you know it's a float .. but take it's address
// and pretend you're looking at an integer and then dereference it"

printf("%d\n", *(int*)&y); //1084227584

Why am i seeing this number?

  • 5 in binary is 0101
  • 5 can be thought of as (1.25 * 2^2), which means that

Can be represented as:

[sign bit]                              - 0
[8 bits worth of exp] - 129 (129-127=2) - 1000|0001
[23 bits of .xxxxxxx] - 25              - 1100|1

Put together, i have

[sign bit][8 bits worth of exp][23 bits worth of .xxx]
0         10000001             11001000000000 //2126336

What am i missing please?

  • 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-02T02:59:18+00:00Added an answer on June 2, 2026 at 2:59 am

    Others have pointed out it’s not portable… but you know this already, and you’ve specified 64-bit OS X. Basically, you have the mantissa wrong. 1.25 is represented with an implicit leading bit for 1.0. The first explicit bit of the mantissa represents 0.5 and the second bit 0.25. So the mantissa is actually: 01000000000000000000000.

    The sign bit 0, and biased exponent 10000001, followed by the mantissa gives:
    0x40a00000 which is 1084227584 decimal.

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

Sidebar

Related Questions

the url format is: domain/startValue/endValue/content here, startValue and endValue take either int or float
Which conversions take place when evaluating the following expressions? char cval; int ival; float
Take the following C code as an example: char buffer1[5]; int* ret; printf(Buffer1 is:
Take this code snippet as example: union stack { int a; float b; };
Im trying to create a method that take 2 int array as the input
I have an int[] array. I need to take an int and append it
to simplify this let take that table: table1 ------------- id unique primary int myVal1
Take this class as example: public class Category : PersistentObject<int> { public virtual string
Take the following snippet: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int foo(char [6]);
Take the following program: #include <cstdlib> using std::rand; #include <iostream> using std::cout; int main()

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.