convert from decimal to binary

David Bonet

New Member
Hi
I am practicing with PICAXE - 20 and would need to know how do I convert decimal data stored to binary data.
(Sorry but my English is not very good)
Best regards
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

Internally data is stored in binary; whether seen to be binary, decimal, hexadecimal or something else depends on how you wish to see it, or how the data is formatted when output in human-readable form.

Perhaps if you could describe what you are attempting to achieve there may be better advice that can be given.
 

westaust55

Moderator
It would be good to describe your project and why you are looking towards or thinking of number conversions.
Conversion between decimal, binary, and/or hexadecimal is really a state of the human mind. The PICAXE chips (and I might suggest virtually all other microcontrollers, microprocessors, etc) store number as binary, irrespective of how humans think of the number. Even BCD is just two 4-bit binary numbers in a byte rather than one 8-bit number.
Have a look at the number conversion chart I created some time ago at post 20 here:
http://www.picaxeforum.co.uk/showthread.php?t=10893&page=2
AS mentioned, within the byte variables, the number is stored in decimal irrespective of whether you assign it as:
Binary using the (%) operator), eg . . . %xxxxxxxx
Hexadecimal using the ($) operator, eg . . . $FFFF
Decimal with no prefix , eg . . . 255 or 65535
 
Top