Andy Android Emulator

Andy is an Android emulator for Windows that claims to support a lot of features. Downloading and installing its 875MB package was easy. On launch, it shows a default VM and allows you to create more with different configurations. However, the VMs did not launch on my Windows 10 computer. Andy would not show any useful error message either.


Operation move disabled on this server


I tried to move or rename a file using the p4 move command. The p4 server responded with this error message:

Operation 'move' disabled on this server


Since the move operation has been disabled by admins on this server, we need to use two operations to simulate a move:

$ p4 integrate old.txt new.txt
$ p4 delete old.txt

How to disable Focused Inbox in MS Outlook

After my email account was moved to Exchange Online, I noticed that my Inbox in MS Outlook client looked different. The All and Unread tabs were replaced with two new tabs: Focused and Other. This was a new feature called Focused Inbox that intelligently was dividing up my Inbox email into these two categories.

After trying it for a few days, I decided I did not need it. To turn it off, go to View → Show Focused Inbox and turn it off.

How to view files over SSH using SimpleHTTPServer

It is convenient to connect to a remote computer using SSH and work at the shell. But viewing images files and other such common files can be a problem. Using a X server might not always be possible. A simple solution that works for me is to use the SimpleHTTPServer module that ships in Python.

  • Change to the directory which holds the files you want to view from a remote computer.
  • Run the SimpleHTTPServer there and provide a port number for the server:
$ python -m SimpleHTTPServer 8901
  • On the local computer, open a browser and connect to the server using the address: http://put-remote-computer-ip-here:8901
  • You can now view image files and other common file types right in the browser.

Tried with: Ubuntu 18.04

Floating point rounding modes in C++11

The standard C library has 4 floating point rounding modes available through cfenv.h. These are now available in C++11 through the header file cfenv.

  • The 4 floating point rounding modes are:
  • FE_TONEAREST rounds to the nearest integer. If the floating point value is exactly midway between two integers, then it does round half to even. The rest of the rounding modes are self explanatory.

  • None of the 4 rounding modes is equivalent to the round half away from zero which the round method does.

  • Anything to do with floating point operations is dependent on the FPU of the processor. So, the availability of these rounding modes and their values are highly dependent on the FPU of your processor.

  • On my x86_64 computer, all the 4 rounding modes were available and the values of these rounding modes were found to be:

#define FE_TONEAREST 0x000
#define FE_DOWNWARD 0x400
#define FE_UPWARD 0x800
#define FE_TOWARDZERO 0xC00
  • The FPU of your processor may support many other rounding modes in addition to these 4 modes.

  • On my x86_64 computer, I found that FE_TONEAREST was the default rounding mode when I used methods like rint and nearbyint to perform rounding.

How to use vimdiff

Vim can be used as a diff and merge tool. While it cannot match the beauty and power of GUI programs like Meld, it is immensely useful to diff and merge over a SSH session.

  • Vim can be invoked in diff mode either using vim -d or as vimdiff. Just pass in the names of the files to compare:
$ vimdiff 1.cpp 2.cpp
$ vim -d 1.cpp 2.cpp 3.cpp
  • Vim in diff mode displays each file in its own window side-by-side showing the diff sections in colors. You can switch between the windows using the normal Vim commands. (I use Ctrl-W-W.) And when you scroll down all the windows scroll down with you because they are locked to each other.

  • To switch to and fro between diffs use the ]-c and [-c commands.

  • To put the diff the cursor is resting on to the next window use the command dp

  • To pull the diff from the next window use the command do

Tried with: Vim 7.4 and Ubuntu 16.04

How to get the C++ standard

The C++ standard is the definitive source for the language. The official standards can be obtained from ISO for a fee. But the draft standard at any point of time can be compiled from its LaTeX source to PDF for free. Here is how:

  • Install these LaTeX packages:
$ sudo apt-get install latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
  • Clone the C++ draft standard repository:
$ git clone
  • Build a PDF of the standard:
$ cd source
$ latexmk -pdf std

If there are too many warnings, you might need to run the above command a second time. The result is a PDF of the C++ standard!

How to get function name in C++

Being able to access and print the function name from any location inside a C++ function can be useful for investigating programs.

There seems to be 3 different function name strings available:

  • __func__ is a constant that only holds the name of the function. It is part of the C and C++ standards.
int A::foobar(const std::vector<float>& fvec, bool isDragon)
    std::cout << __func__ << std::endl;
    // Output: foobar
  • __FUNCTION__ is a GCC constant whose output is exactly the same as __func__.

  • __PRETTY_FUNCTION__ is a GCC constant that is more useful for C++, because it holds the entire function signature:

int A::foobar(const std::vector<float>& fvec, bool isDragon)
    std::cout << __func__ << std::endl;
    // Output: int A::foobar(const std::vector<float>&, bool)

Reference: GCC: Function names as strings

How to round half to even

The round function available in C and C++ uses the rounding mode called round half away from zero. In this mode, the floating point value is rounded to the nearest integer value. When the floating point value is exactly midway, then the integer value away from zero is picked.

Many applications require the rounding mode to be round half to even. In this mode, when the floating point value is midway, the integer value that is even is chosen.

If you need round half to even, then you use the nearbyint or rint methods and set the rounding mode to FE_TONEAREST before you use them. For more information on these rounding modes, see this post.

#include <cfenv>
#include <cmath>
std::fesetround(FE_TONEAREST); // This is the default rounding mode for std::nearbyint
std::nearbyint(3.5f); // Result is 4
std::nearbyint(4.5f); // Result is 4

FE_TONEAREST is the default rounding mode, so you do not need to actually set it. Unless you believe it was set to some other rounding mode earlier in your code.

If you wish to do this rounding manually, then here is one possible implementation with test code: