Skip to content

Sort a byte if selection in highest-lowest value

License

Notifications You must be signed in to change notification settings

kezoponk/bytesorter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 

Repository files navigation

Bytesorter

Sort a byte if selection in highest-lowest value, tested on both python & java

Setup

# Java(TM) SE Runtime Environment (build 13.0.2+8)
javac bytesorter.java
java bytesorter

Example

Input
byte byteVar = 0b0101;

if (( byteVar & 0b0001 ) == 0b0001 ) {}
else if (( byteVar & 0b0010 ) == 0b0010 ) {}
else if (( byteVar & 0b0011 ) == 0b0011 ) {}
else if (( byteVar & 0b0100 ) == 0b0100 ) {}
else if (( byteVar & 0b0111 ) == 0b0111 ) {} // This returns true even though
else if (( byteVar & 0b0101 ) == 0b0101 ) {} // This one is more accurate
else if (( byteVar & 0b0110 ) == 0b0110 ) {}
else if (( byteVar & 0b1000 ) == 0b1000 ) {}
Output
if (( byteVar & 0b0001 ) == 0b0001 ) {}
else if (( byteVar & 0b0010 ) == 0b0010 ) {}
else if (( byteVar & 0b0011 ) == 0b0011 ) {}
else if (( byteVar & 0b0100 ) == 0b0100 ) {}
else if (( byteVar & 0b0101 ) == 0b0101 ) {}
else if (( byteVar & 0b0110 ) == 0b0110 ) {}
else if (( byteVar & 0b0111 ) == 0b0111 ) {}
else if (( byteVar & 0b1000 ) == 0b1000 ) {}

Made partly for fun &

About

Sort a byte if selection in highest-lowest value

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages