A common request I get for Console Calculator is support for a bitwise NOT operator (the ~ symbol in many programming languages).Â The reason I have not yet implemented this is that CCalc has a very large intrinsic bit width (200+ bits).Â A proper NOT operator cannot ignore leading zeros, so how many bits should I limit to?Â Should ~0x80 be 0x7F or 0xFF7F or 0xFFFFFF7F, etc.
Anyway, you can define your own NOT function to the bit width you prefer.
Below are a few additional useful functions which I like to have around.
Do you have any useful custom functions you’ve defined?Â Comment.
Michael · March 21, 2010 at 2:51 pm
Heres a few small ones I use for handling timecodes on video/audio. They can probably be simplified further, but they do the trick.
fps(x) -> converts frame rate to high precision floating point value, ie fps(24), ans = 23.976024
sec2min -> converts seconds to minutes in format sec.microsec, ie 1463.558s to 24.23558 ( 24:23.558 )
min2sec -> converts minutes to seconds in format min.sec+microsec, ie 24.23558 to 1463.558
atm(x,y) -> adds 2 min.sec timecodes
mtm(x,y) -> subtracts 2 min.sec timecodes
tm2fr(min.sec,int fps) -> converts min.sec timecode to frame number at int fps framerate, ie the frame number at 24:23.558 with video frame rate of 23.976fps,
ans = 35090
So at that timecode and frame rate, the resultant frame will be 35090.
fr2tm(int frame number, int fps) -> converts back from frame to min.sec timecode.
ans = 24.2354542
this will be with half a frame of the target timecode, quite hard to get this one perfect without checking the video yourself.
Jake · December 14, 2010 at 12:55 pm
You could also define a variable-width not function:
not(bits, x)=((2^bits – 1)-x)