- Erlang - Web Programming
- Erlang - Drivers
- Erlang - Performance
- Erlang - Concurrency
- Erlang - OTP
- Erlang - Distributed Programming
- Erlang - Ports
- Erlang - Databases
- Erlang - Emails
- Erlang - Processes
- Erlang - Funs
- Erlang - Binaries
- Erlang - BIFS
- Erlang - Guards
- Erlang - Pattern Matching
- Erlang - Preprocessors
- Erlang - Header Files
- Erlang - Macros
- Erlang - Exceptions
- Erlang - Records
- Erlang - Tuples
- Erlang - Maps
- Erlang - Atoms
- Erlang - File I/O
- Erlang - Lists
- Erlang - Strings
- Erlang - Numbers
- Erlang - Recursion
- Erlang - Modules
- Erlang - Functions
- Erlang - Decision Making
- Erlang - Loops
- Erlang - Operators
- Erlang - Variables
- Erlang - Data Types
- Erlang - Shell
- Erlang - Basic Syntax
- Erlang - Environment
- Erlang - Overview
- Erlang - Home
Erlang Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Erlang - Binaries
Use a data structure called a binary to store large quantities of raw data. Binaries store data in a much more space efficient manner than in psts or tuples, and the runtime system is optimized for the efficient input and output of binaries.
Binaries are written and printed as sequences of integers or strings, enclosed in double less than and greater than brackets.
Following is an example of binaries in Erlang −
Example
-module(helloworld). -export([start/0]). start() -> io:fwrite("~p~n",[<<5,10,20>>]), io:fwrite("~p~n",[<<"hello">>]).
When we run the above program, we will get the following result.
Output
<<5,10,20>> <<"hello">>
Let’s look at the Erlang functions which are available to work with Binaries −
Sr.No. | Methods & Description |
---|---|
1 |
This method is used to convert an existing pst to a pst of binaries. |
2 |
This method is used to sppt the binary pst based on the index position specified. |
3 |
This method is used to convert a term to binary. |
4 |
This method is used to check if a bitstring is indeed a binary value. |
5 |
This method is used to extract a part of the binary string |
6 |
This method is used to convert a binary value to a float value. |
7 |
This method is used to convert a binary value to a integer value. |
8 |
This method is used to convert a binary value to a pst. |
9 |
This method is used to convert a binary value to an atom. |