Jump to content

Recommended Posts

Posted

What is the difference of writing this:

MIOS_MIDI_TxBufferPut(0x06)

and this:

MIOS_MIDI_TxBufferPut(6)

I notice this in looking at other peoples source that hex and decimal notation is used interchangably.

P.S.

I have 80% of my hardware completed and mounted in 2 cardboard boxes so I have something to write software to before I decide on the front panel design.

It's very exciting to see my project come together and even more so when I can almost tweak every audible characteristic of the matrix sounds with my knobby programmer.

I've ordered some more parts from SmashTV and those will allow me to complete the 5 point tracking/reshaper, ramps and portamento section of the front panel.

I've also ordered a larger LCD (2x20) which I havn't added yet which is part of the final electronic component, the programmer section.

Posted

there are no difference between

MIOS_MIDI_TxBufferPut(0x06) and MIOS_MIDI_TxBufferPut(6)

but there' is a big one with MIOS_MIDI_TxBufferPut(0x10) and MIOS_MIDI_TxBufferPut(10)

0xValue Mean hexadecimal value.

The value 'alone' mean it's a decimal value.

Posted

0x10 has the decimal value of 16 ( 0x10 = (2*8 + 1*0) )  ;) 

<edit> see below! Seppoman explains it right, and I'm the one who gets an F in his Math Exam... like always  :-[ </edit>

hex gets counted from 0 to 7 15 (as the name implies),

decimal from 0 to 9 (dito)...

as the computer treats all numbers in the last instance as binaries (0 or 1), it's upon you what makes more sense to use...

eg. channel calculations are a lot easier to implement in hex than in dec.

See http://www.midibox.org/dokuwiki/doku.php?id=midi_specification

Regards,

Michael

Posted

Hi Michael,

0x10 has the decimal value of 16 ( 0x10 = (2*8 + 1*0) )  ;)

hex gets counted from 0 to 7 (as the name implies),

I´m sorry, but this is not correct. Hex gets counted from 0 to 15 - as the name implies, because the full name is "hexadecimal" which means 16. From 0 to 7 would be the octal system which is not used in programming (or nearly anywhere else ;) ).

About hex to decimal conversion: Just as decimal e.g. 25 means 2*10 + 5*1, hex 0x10 means 1*16 + 0*1. The digits from right to left in all systems mean (number * (base to the power of the digit )) - the digit is counted from 0. So with hex it is


digit:   ...       3                  2              1               0

power :  ...       16^3               16^2           16^1            16^0

equals:  ...       4096               255            16              1

so e.g. a 4 digit hex value of 0x3A20 means (3*4096 + 10*255 (A hex=10 dec)  + 2*16 + 0*1) = 14870 :)

The reason why hex is often used in programming is that it converts quite nicely to binary. Each binary "Nibble", that is 4 bit, is represented by one hex digit, that´s because 4 digits binary also represent numbers from 0 to 15. So you can calculate the binary value of large hex numbers in your head and don´t have to use a calculator all the time.

Greetings from Nerd-Land :)

Seppoman

Posted

of course!

Thank you for correcting this :) maybe I've been so in hurry, that I divided everything /2 ;D

sorry for this misinformation; I cannot explain why I wrote that, 'cause in principle I should know it (heck I even use it all the time 0xf :doh!: )

Cheers!

Michael

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...