Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - 日本語 - Русский
Scilab Help >> Elementary Functions > Bitwise operations > bitstring

bitstring

A string giving the literal bit representation of a number

Syntax

str = bitstring(x)

Arguments

x

a matrix of integers, real doubles or booleans

str

a matrix of strings

Description

bitstring returns a string giving the literal bit representation of a number.

Examples

// IEEE_754 Floating point number
str = bitstring(%pi)
mprintf("sign bit = %s\n",part(str,1))
mprintf("exponent = %s\n",part(str,2:12))
mprintf("mantissa = %s\n",part(str,13:$))

// see periodic pattern in mantissa
bitstring([1/3; 1/5; 1/7])

// see last bit of mantissa
bitstring([1; 1+%eps])

// special IEEE_754 values
bitstring([0 -0])
bitstring([%inf; -%inf; %nan; -%nan])

// integer types
bitstring([%t %f])
bitstring(int8(-1))
bitstring(uint16(65535))
bitstring(int32(-65535))
bitstring(uint64(-1))

See also

  • bitget — Extracts from integers bits of given indices
  • bitset — Sets bits of given indices in some integers

References

Implementation of IEEE Standard for Floating-Point Arithmetic can be found at https://en.wikipedia.org/wiki/IEEE_754

History

VersionDescription
6.1 Function bitstring added
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:49:18 CET 2020