Skip to content
Snippets Groups Projects
Select Git revision
  • 1eae8dbcdfb56fecea20df44543f132cd5bc64ec
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

bc_ternary_demultiplexer.go

Blame
  • user avatar
    Wolfgang Welz authored
    b5ec7827
    History
    bc_ternary_demultiplexer.go 731 B
    package ternary
    
    import (
    	. "github.com/iotaledger/iota.go/trinary"
    )
    
    type BCTernaryDemultiplexer struct {
    	bcTrits BCTrits
    }
    
    func NewBCTernaryDemultiplexer(bcTrits BCTrits) *BCTernaryDemultiplexer {
    	this := &BCTernaryDemultiplexer{bcTrits: bcTrits}
    
    	return this
    }
    
    func (this *BCTernaryDemultiplexer) Get(index int) Trits {
    	length := len(this.bcTrits.Lo)
    	result := make(Trits, length)
    
    	for i := 0; i < length; i++ {
    		low := (this.bcTrits.Lo[i] >> uint(index)) & 1
    		hi := (this.bcTrits.Hi[i] >> uint(index)) & 1
    
    		switch true {
    		case low == 1 && hi == 0:
    			result[i] = -1
    
    		case low == 0 && hi == 1:
    			result[i] = 1
    
    		case low == 1 && hi == 1:
    			result[i] = 0
    
    		default:
    			result[i] = 0
    		}
    	}
    
    	return result
    }