How to create and configure Amazon ElastiCache cluster

Couple of days ago, I was working with Amazon ElastiCache. I was trying to access it from my local machine.
Amazon ElastiCache can be accessed within Amazon network only and not from outside the network.
Below are the steps to create and configure Amazon ElastiCache to use in the consumer application.
1. You can access the Amazon ElastiCache from Amazon EC2 instance. If you are yet to create the Amazon EC2 instance, please visit this link.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html
2. When you are ready with the EC2 instance, you will see something like this;











3. Then you need to select Amazon ElastiCache from the services section.













4. When you click to the Launch Cache Cluster button, you will be redirected to a wizard, where you need to specify parameters.













The highlighted sections are important to note down. Amazon ElastiCache is a paid service. So you have to be very careful while selecting node type. Engine depends on which client you are making use of. Since it is in Beta phase, Amazon Cache cluster must reside on the same region where EC2 instance is created.


5. In the next screen you can select the security group.












In this screen you need select the same security group which you have used while creating EC2 instance.

6. You can review all the parameters in next screen and start launching cache cluster.

Tweak in Double.ToString() conversion

I am working on an application which involves lot of arithmetic operations. In this application we heavily make use of double and string interchangeably.
I was facing a problem with conversion between double type to string variables.

Consider below code;
1
2
double d = 30.235312769517968;
string convertedValue = d.toString();

If we see the output of convertedValue variable it gives us something like 30.235312769518, which fails the comparison.
To preserve the decimal precision we can make use of ToString() as below;

1
string convertedValue = d.ToString("R");

By default, the return value only contains 15 digits of precision although a maximum of 17 digits is maintained internally. If the value of this instance has greater than 15 digits, ToString returns PositiveInfinitySymbol or NegativeInfinitySymbol instead of the expected number. If you require more precision, specify format with the "G17" format specification, which always returns 17 digits of precision, or "R", which returns 15 digits if the number can be represented with that precision or 17 digits if the number can only be represented with maximum precision.

Note that not all the numbers can be represented exactly...