Problems with my Nibble Swap Programming Software Development by Paul.Esson The following method should swap the high nibble in a byte with the low nibble in a byte. The following code dosn't… work if the lower nibble is above 0111 if it is it returns a negative… Re: Problems with my Nibble Swap Programming Software Development by Paul.Esson … keep the sign (not what i want ).. [CODE]// My new nibble swap private static byte nibbleSwap(byte inByte){ int nibble0 = (inByte… Re: Binary formatting for output "Nibble isolation" Programming Software Development by TrustyTony … representation string: [CODE]## 1) do it yourself with masking def nibble(n,x): ## mask 0b1111 shift up, mask, shift back return…(8)): ## bin, take out 0b, zerofill and print print (bin(nibble(i,x))[2:]).zfill(4), print ## 2) other way if… Binary formatting for output "Nibble isolation" Programming Software Development by niehaoma …. Purpose: Take a 32-bit value (tempCode) and output each nibble. My way was to use a string, basically shifting out… Re: Problems with my Nibble Swap Programming Software Development by server_crash [QUOTE=Paul.Esson]in java are signed bytes and the signed bit is the last bit... [/QUOTE] The signed bit is the first bit, the leftmost bit. 1001 0000 0000 0000 0000 0000 0000 0000 The signed bit is a 1. -- negative I think you got it, you just said the wrong thing! Re: Problems with my Nibble Swap Programming Software Development by Paul.Esson [QUOTE=Paul.Esson] Example: 10010100 - Signed Bit on neg number 01001001 - Signed bit off positive number. [/QUOTE] Thats the leftmost number :P, or if your counting, the last bit... highest bit.. I guess would be a more approprate term Re: Problems with my Nibble Swap Programming Software Development by server_crash [QUOTE=Paul.Esson]Thats the leftmost number :P, or if your counting, the last bit... highest bit.. I guess would be a more approprate term[/QUOTE] I see where your coming from. I guess it doesn't matter how you look at it, as long as you get it. Re: Problems with my Nibble Swap Programming Software Development by Waqas_Moeed public static void main(String[] args){ byte inByte = (byte)0x09; byte out; int by1 = (inByte & 0x0f) >> 0 ; int by2 = (inByte & 0x0f)>> 4; // <-- System.out.println(by1); System.out.println(by2); out = (byte)((by1 << 4 | by2 << 0) & 0xff); System.out.println(out); } Try … Re: Problems with my Nibble Swap Programming Software Development by javaAddict [QUOTE=Waqas_Moeed;853083] Try this one.... Regards .................[/QUOTE] Congratualtions, The oldest thread reviving I have ever seen. Not to mention all the forum rules that you've just broken. (We do not give away free homework and we use code tags) Last post by [I]server_crash[/I] was [B]May 8th, 2005 14:16[/B]. What were you … Re: Binary formatting for output "Nibble isolation" Programming Software Development by niehaoma Awesome. Thank you for the reply, it helps is seeing other methods to do the same thing. Though I do prefer the 32-bit output to remain on a single line. Is there a way when using PRINT in a loop, to not automatically include a carriage return? Re: Binary formatting for output "Nibble isolation" Programming Software Development by TrustyTony print does not automatically include carriage return, but does add space between inputs. It adds carriage return only if you do not finish print with comma(,). Output of my code is [CODE]>>> 0000 0000 0000 0000 0000 1111 0000 1010 0000 0000 0000 0000 0000 1111 0000 1010 >>> [/CODE] If you want not to have space between printed … Re: Binary formatting for output "Nibble isolation" Programming Software Development by niehaoma See, look at my C-coding skills causing errors. I thought that comma was a typo ;) Thanks. I like the condensed code in option 2 above. Re: union usage problem Programming Software Development by Alex Edwards …;); friend istream& operator>>(istream&,Nibble&); }; inline Nibble::Nibble(int n) : number(n) { cout <… ostream& operator<<(ostream& nout,const Nibble& n) { return nout << n.number…; } istream& operator>>(istream& nin,Nibble& n) { /* error here // error : In function… union usage problem Programming Software Development by ++C LOVER … friend istream& operator>>(istream&,Nibble&); }; inline Nibble::Nibble(int n) : number(n) { cout &…number; } istream& operator>>(istream& nin,Nibble& n) { /* error here // error : In …return nin >> n.number; } int main() { Nibble n1; cin >> n1; cout << &… Re: union usage problem Programming Software Development by Duoas …anyone has addressed the original design problem. While having a 'nibble' class would be cool, it is impractical. The basic … a minimum of seven other bits. Thus, a single nibble is convenient until you have to use it somewhere. Trying… to read and write a nibble from file illustrates the problem quite nicely. You [i]… Understanding: SBI Set Bit in I/O Register Programming Software Development by Dwarrel …Using temp for that. sbr temp, 0b11110000 ;set high nibble in temp out DDRD, temp ;write value to DDRD … pop argument ;restore the argument, we need the low nibble now... cbr temp, 0b11110000 ;clear the data bits of… ;the LCD data lines, which are the HIGH port nibble! cbr argument, 0b00001111 ;clear unused bits in argument or… Re: union usage problem Programming Software Development by ++C LOVER …. that I want to do in my new data type Nibble. [QUOTE=Alex Edwards;665425] --it compiles, though it may not… be accurate to the definition of a Nibble. [/QUOTE] Ya! I know it compiles, and runs! but whatever… Re: union usage problem Programming Software Development by CoolGamer48 … it's trying to access a private member of a nibble. Re: union usage problem Programming Software Development by CoolGamer48 … with this. The streams are declared friends of the class Nibble so they should have the right to access private data… Re: union usage problem Programming Software Development by Ancient Dragon … to change the code to provide an extraction operator for Nibble. Basic question about endianness Programming Software Development by pdk123 Hello, Is the endianess can be for the nibble boundaries ? Because i have defined a class, and try to …, as i have a very big structure with access to nibble boundaries, will make it more complex for me to determine… MIDI (winmm.dll) And Callback Functions Programming Software Development by Quick2010 … If 'byte 2 is split into nibbles. MS Nibble is Message Type, LS Nibble is Message byte2 = dwParam1 >> 8 nibble1… Re: Do you bite your nails? Community Center Geeks' Lounge by Lardmeister [quote=The Dude;458239]I dont nibble on mine....[/quote]Does that mean that you nibble on other people's fingernails? Strange habit! Re: unsigned integer Programming Software Development by deceptikon … is also ambiguous. Are you reversing the bits in each nibble or swapping the nibbles? Anyway, without actually solving the problem… better presentation */ if (last % CHAR_BIT == 0) putchar(' '); /* Break at the nibble boundary too. This places a double break at the byte… Do you bite your nails? Community Center Geeks' Lounge by The Dude I dont nibble on mine.... Define Type of Assembly Programming Software Development by Fong~ … byte as HEX for LCD swapf STORE2,W ;get tens nibble andlw 15 movwf STORE1 addlw 6 btfss STATUS,DC goto… this que is damn hard can anyone help me?? Programming Software Development by zhe05303 … through combination of several processes such as byte level interleaving, nibble level interleaving, bit level interleaving, rotation, masking, translation table and… Getting negative nibbles. Programming Software Development by Brianbc This Christmas day, I am plagued by this negative nibble mystery. I have some bytes in a byte array that … Serial Error Programming Software Development by nsyncpilu …;); break; case ParallelPort.LPT_MODE_NIBBLE: System.out.println("Mode is: Nibble Mode."); break; case ParallelPort.LPT_MODE_PS2: System.out.println("… unsigned integer Programming Software Development by shashikumar s g to input an unsigned integer and reverse the first and last nibble of the number