Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

bitFieldInsert()

Purpose

Insert a number of bits into a binary number

Description

Insert the specified bits into a 32 bit signed binary number starting at the specified bit

Syntax

  result = bitFieldInsert( number, start, count, value )

Arguments

number 32 bit signed binary number

start Start position (first position is 0)

count Number of bits to insert

value Bits to insert

result resulting number when bits have been inserted

Example

loop
    textSize( 50 )
    byte1 = 0
    byte2 = 15
    printAt( 0, 0, "byte1 =                                ", bin2str( byte1 ) )
    printAt( 0, 1, "byte2 =                                ", bin2str( byte2 ) )
    result = bitFieldInsert(byte1, 2, 4, byte2)
    printAt( 0, 2, "bitFieldInsert( byte1, 2, 4, byte2 ) = ", bin2str( result ) )
    update()
repeat

function bin2str( byte )
    result = ""
    for i = 0 to 8 loop
        bit = byte & 1
        if bit then
            result = "1" + result
        else
            result = "0" + result 
        endIf 
        byte = byte >> 1
    repeat
return result

Associated Commands

bitCount(), bitGet(), bitSet(), bitFieldExtract(), bitFieldInsert(), leadingZeroes(), trailingZeroes()

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.