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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:10:25+00:00 2026-05-23T14:10:25+00:00

Got another Erlang binary representation query (‘coz that’s what I am reading about these

  • 0

Got another Erlang binary representation query (‘coz that’s what I am reading about these days, and need for binary protocol implementation).

If I understand the type-specifier properly, then, for a “float” type value the 8 byte representation seems fine (this is on 64-bit Win7).

1> <<A1/binary>> = <<12.3214/float>>.
<<64,40,164,142,138,113,222,106>>

However what stumped me, was that the “integer” type value’s binary representation.

2> <<A2/binary>> = <<32512/integer>>.
<<0>>
3> <<A3/binary>> = <<232512518/integer>>.
<<6>>
4> <<A5/binary>> = <<80/integer>>.
<<"P">>

Why are all of those represented in 1 byte ? Can someone please explain this ?

  • 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-23T14:10:26+00:00Added an answer on May 23, 2026 at 2:10 pm

    You’re not converting Erlang terms to their binary representation. You’re using the binary syntax to build binaries. Using integer will truncate them to fit into one byte:

    3> <<255/integer>>. % Under one byte
    <<"ÿ">>
    4> <<256/integer>>. % "Over" one byte
    <<0>>
    

    Try this:

    5> term_to_binary(32512).
    <<131,98,0,0,127,0>>
    6> term_to_binary(232512518).
    <<131,110,4,0,6,220,219,13>>
    7> term_to_binary(80).
    <<131,97,80>>
    

    131 is the version number, 97 is a small integer (8-bit), 98 is a big integer (32-bit), 110 (and 111) are for bignum integers. The rest is the data for the actual numbers.

    See the documentation for the Erlang binary term format for further info on what the bytes mean.

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

Sidebar

Related Questions

I've got a test class in a module that extends another test class in
I've got a Perl script that needs to execute another Perl script. This second
I need some help in combining a stored procedure with another function. I've got
I've got another simple one (I think) that's stumping me. I have written a
I got another question about .htaccess: I want every param which is given to
I've got another newbie question. I've written a piece of code that converts a
So I've got one solution that compiles to a C++ DLL I've got another
I've got another question at chef deployment? that is perhaps a little too broad
Regarding my previous problem that is now fixed, I got another problem with the
I've got another problem in the same code... I'm getting this error: initialization method

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.