DIG it

Jeremy Leach

Senior Member
Just noticed in manual 2, under variables- mathmatics, the DIG function:
DIG
The DIG (digit) command returns the decimal value of a specified digit (0-4,
right to left) of a 16 bit number. Therefore digit 0 of ‘67890’ is 0 and digit 3 is ‘7’.
To return the ascii value of the digit simply add ascii “0” to the digit value e.g.
let b1 = b2 DIG 0 + “0”
And searching on the forum produced no hits. I've never noticed it before, so just wondered if it's something everyone else has missed ! Could be handy.
 

BeanieBots

Moderator
Good point Jezz. Maybe we are all too used to doing it the hard way with "/","//" and +"0". (keep forgetting about #var as well!)
Doing some "floating" maths to display on LCD as we speak. Will have to investigate this one.
 

westaust55

Moderator
DIG, REV , INV, NCD, and DCD are commands I have been using in some of my code for such things as LED bar-graphs, compass LED displays, drivers for ex mobile phones gLCD, and for various computed maths (as opposed to lookup tables), etc.

Had previous spied an error wrt the DCD command in the manual 2 which Rev Ed has now corrected in latest version.
 
Last edited:

BeanieBots

Moderator
Time for me to read the whole manual through again I think.
Should probably also update my 2004 printed version as well.:eek:
No mention even of "if/then/else" in there, let alone X1.
Maybe I'll wait for the X2:p
 

hippy

Ex-Staff (retired)
One of the reasons we don't hear more about DIG and the like is probably that they apply to the X1 ( and X2 ) only so, while very useful, most example code we give tends towards being generic and suitable for any PICAXE. That in turn then leads us to forget about the more advanced operators. A particular example is that we will usually use multiply and divide rather than shift operators ( << and >> ).

I too have missed new commands and operators. That comes down to not reading the manual, not spotting the additions and changes and not realising new firmware supports commands the firmware one is currently using does not. What is perhaps needed is a "what's new" document which summarises additions when new stuff is released.

One thing I recommend is to check firmware.txt and revision.txt whenever a new version or patch for the Programming Editor is installed.
 
Top