Bits - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Bits : Bits/String

Bits

  

String

  

convert base-10 number to a base-2 number in string form

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

String(number, options)

String(number, lsbfirst, options)

String(number, msbfirst, options)

Parameters

number

-

a nonnegative integer

lsbfirst

-

literal indicating string should have the least significant bit first

msbfirst

-

literal indicating string should have the most significant bit first

options

-

bits option

Description

• 

The String command converts the input number to a base-2 string, by default in least-to-most significant bit order. Specification of the option msbfirst reverses the order in the output string to most-to-least significant bit order.

• 

The most common usage of this command would be for conversion of a number into a string of its base-2 digits.

The Split command is closely related, but the output for that command is a list of integers.

• 

The option bits=n tells String how many bits to consider in the conversion. Any bits in a higher position are simply ignored.

The number of bits can also be set via Settings.

Examples

withBits:

String255

11111111

(1)

String1+2+4+256

111000001

(2)

lsbfirst is the default

String1+2+4+256,lsbfirst

111000001

(3)

msbfirst reverses the order

String1+2+4+256,msbfirst

100000111

(4)

Truncate at bit 8

String1+2+4+256,lsbfirst,bits=8

11100000

(5)

String1+2+4+256,msbfirst,bits=8

00000111

(6)

See Also

Bits

Split

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam