h1

Why use Big Decimal in java

July 11, 2010

When we work with decimals in certain financial related calculations, we see that certain numbers get rounded off incorrectly even though they are stored in double. Below is the example:

public static void main(String o[])
{
double d =3.14159265358979353d;
System.out.println(d);
}

Output is :

3.1415926535897936

It makes sense to have the value as 3.1415926535897935 but not the one that is printed. The reason is double cannot store the right precision for floating point numbers and if you need to store the precision correctly, you need to use Big Decimal. A very good article of using big decimal can be found here

h1

Java Titbits – Filtering files

July 8, 2010

We would have encountered scenarios where we would want to filter certain files within a directory. The traditional method is to get all the files and run through that list and select those that you need. But java  does provide a fileNamefilter class or a fileFilter class that you can use while listing all the files within a directory. (And this has been in jdk since version 1.0 .. something that i didnt know.)

An example to filter all jpeg files in a directory C:\pictures

File myDir = new File(“C:/pictures”);

File[] contents = myDir.listFiles(new FileNameFilter() {

public boolean accept(File directory, String fileName) {

return (fileName.endswith(“jpeg”));

}

} );

You can also use FileFilter if the accept method needs to use any attributes of file object.

h1

My Take on Tata Nano

January 13, 2008

No No, this isn’t another post to talk about the launch of Tata’s 1 lakh car or about its features or Specs. Theres load of information over the internet regarding this. This post is about why or who should buy a Nano? Or should one buy Nano ? Lets compare Nano with Maruti 800 to see where it stands. Maruti has higher engine capacity at 796cc compared to Nano’s 673cc.But Nano is smaller compared to Maruti 800 yet has larger space inside comparatively. Thats a great achievement. Thats because the engine in Nano is fitted at the back similar to an auto. Parking should be much easier now and so should be finding spaces to park.In terms of fuel mileage there is not much difference. Tata’s claim that Nano will give 20 km per litre and maruti gives around 21 Km per litre. But a lot of difference lies in the price. Maruti 800′s base model is priced at 1.94 lakhs + taxes and Nano’s base model is priced at 1 lakh. That means people can buy 2 Nano instead of 1 Maruti :) And thats exactly what has happened. Lot of them have postponed their decision to buy a car waiting for Nano. And most of them are planning to buy more than one car. Tatas have created a revolution by launching such a low cost car. This has posed a tough competition for others in the industry. Given the traffic condition in each metro, people find there is no use of buying high-end vehicles and SUV’s. You will never get to drive at such fast speeds because of traffic and a signal placed at every arm’s length. My manager is planning to sell his Ford Fusion and get a Nano if its a hit. And why not? given that his family comprises of just 4 people Nano will serve that purpose. My point is this car is a steal especially for those married coupled who have a baby. We know that driving bike with baby in hand is risky. Such couples get stranded in their houses as they hesitate to take the baby along in the bike. They will be yearning for Nano. A typical family in a metro comprises of 2 adults and a child. Given they stay in metro, Nano should be very much affordable. A typical family living in a tier-2 cities say (ex:coimbatore) will comprises of 4 adults and a child. Nano too can fit them all. Working women too would go for Nano. Those who use public transport will find this affordable provided they have been given attractive EMIs to pay off auto loans. And those who use scooty/honda/pleasure will go for Nano as it is much safer to ride a 4-wheeler than a 2-wheeler (for themselves ofcourse). And not to forget the Cab Drivers. These where the people who waited for tata nano much more than any other. To ferry employees of MNCs from office to home and home to office,Nano would be the best-fit. But there is a small problem. When Nano starts be used as a cab, people will hesitate to buy it. Remember what happened to Tata Indica. Tata would be better off if it has different color variants so that cabies go for white color and other buyers go for colors like metallic-grey. I mean any color that signifies great style and finishing. They might come with a pink variant to attract women buyers too.
What could jeopardize their plans ? Frequent maintenance needed for the vehicle and poor after sale service. Maruti is just so good at this. The Traffic. Just imagine if so many cars get on roads in cities like bangalore and hyderabad. Driving would become a nightmare. Car’s engine is good enough to pull load of 4 Adults. Given the roads in hyderabad where there are very hilly, there remains concerns whether Nano can climb such hilly roads with 4 people in it and say AC is on ? How much is the ground clearance ? safety concerns for the driver incase the car crashes headon. Is there a diesel variant ?
If Nano fares well in each of this parameter then they have revolutionized the auto industry. But that said, Tatas have done an excellent job. Making a promise of launching a 1-lakh car inspite of none in the industry believing in it and keeping up the promise is no mean feat.Kudos to Tata and their team behind this project.

Powered by ScribeFire.

h1

Top Ten Firefox Add ons

January 12, 2008

Well you would have come across most of the content posted here. Moreover some of the addons that i have bumped upon are from the tech blogs i visited. I have compiled all of them and listed my favourites here. Most of the addons mentioned would be of help to developers who surf a lot . So without much ado here they are:

1. Stumbleupon – Gateway to surf the best of the internet. It also provides features to bookmark the visited sites and share it with friends and build communities based on your interests. A must for an avid surfer

2. SessionManager – Nice to have addon that helps you to save all the links and restore them when needed. Generally i open a lot of links in my browser and when i need to take a break, i save the entire session using session manager so the next time i restart my laptop i can get to where i left by restoring the entire session.Quite helpful.

3. Send Tab Urls – Another helpful addon i use when i browse at office. It so happens that i cant continue browsing web pages at office and intend to browse them at home at my convenience. But i would need to start it all over from scratch had it not been for this addon. This addon helps me in saving all the links into a mail and send it to a mail address. So when i reach home all i do is open all the links and recontinue my work from where i left at the office. Alternatively the same can be done by saving the session using session manager and sending the .session file created to your email. At your home you just need to save the file at %LOCAL_USER%\Application Data\Mozilla\Firefox\Profiles\1hju3cck.default\sessions

4. Roboform- The needed info is already available in the preceding post.

5. Firebug – A must addon for any web developer who deals with CSS and Java script. Noteworthy feature is that it allows you to edit javascript/CSS and execute it on the fly and see the results.

6. Imacros – Hmm, we have roboform which automates authentication to websites like gmail,yahoo,wordpress,etc. Infact these are the sites that i initially visit. What if there is a means to automate launching all these sites so that in one click all these sites open and i m logged with my account. Thats where Imacro is of use to me. Just as their website say you can automate anything that firefox does.

7. AutoCopy – A software developer survives on the basic skill needed in IT industry: Ctrl+C..Ctrl+V. This addon typically increases productivity of the developer by copying any selected text to the clipboard.

8. Fox Marks Sychroniser – A addon for managing your bookmarks across your computers. I browse a lot at office and any worthy link i add it to my bookmark. I use this tool to create a repository of them at a server and at home i come and syncronise my local bookmarks with that on my server. By doing this i dont stand to lose any of my bookmarks incase my PC crashes.

9. Downthemall – Useful when you are downloading and saving pages on your computer.

10. FireScribe – This is just a fill in. Just to bring the number to 10. Neverthless useful to bloggers who intend to publish their posts in various blogging sites like wordpres, blogger etc.

Hope you found these addons as useful as i did.

~ Maverik

h1

Some internet utilities part – II

January 4, 2008

As promised, here is my next quota of utilities that i found useful on internet. Top on my list is roboform . Well this is a browser addon that can manage passwords for all your sites. Whenever you enter your username and password for any website, roboform stores them so the next time you visit those sites you just need to select the website name in roboform toolbar and it will fill the username and passwords and automatically log you in. There are host of other useful features. You can check them out here . I like the auto fill feature wherein you can create an identity for yourself and then wherever you need to register just click on the identity and select fill forms and roboform fills common details like first name, last name, email id etc.

Other utility i found useful is crossloop. This software is really useful when you want to remote desktop to any machine over internet. Helps when your troubleshooting your brother’s or your family’s PC. You can right away download and use it. There is a nice article on this available here.When i tried to connect to my friend’s laptop over internet it was very slow. it takes a lot of time to render. Instead i would suggest him to put his laptop over internet so that i can remote desktop. That would be a little faster. Yet this tool is very handy when the other party is naive at using computers.

Hmm..well someday i ll also write some must have firefox add-ons that increase your productivity and ease certain manual tasks.

Till then,Its good bye from your host.

~ Maverik

h1

Some internet utilities part – I

January 1, 2008

This post is to share with you some tools and utilities that i have bumped upon while i keep surfing the internet. A few of them are freewares and a few of them are commercially sold. These tools have helped me increase my efficiency and provide accesability and i hope you find them as useful as i did.

So first to start with is Purplenova web server. This easy to install and configure software is useful when you want to host your files and access the same from internet (that means from anywhere). I have run this ftp software from my home laptop so that i can access certain files from my office. Apart from providing plain ftp access, this software provides a host of other features like hosting web sites, exposing web services, etc. Although these features come with the commercial version :( . A cool feature is that you can subscribe to RSS feeds so whenever i upload a file you can get a notification. Another one is you can categorise your files for public or private access. The file that is only privately shared has to be accessed by hitting the url. I have created my internet share at http://maverikpro.purplenova.net/ .

Next on my list is Terminals.A remote desktop client which you can use to store and configure different RDP connections. Earlier I used to save each RDP connection on desktop and double click them when i needed to connect. Managing all the saved connections was cumbersome and the desktop looked ugly . This utility manages all the connections without making your desktop look ugly. Since it shows each connections in a tabbed pane, switching between connection is easy. A must download for anyone who remote connects to different hosts for file upload, deploy, troubleshoot etc.

Well will end the Part one of this post here. Stay tuned to for more updates on this topic

And Wish you a very happy and a prosperous new year 2008

-Maverik

h1

Updates about my blog

December 16, 2007

A few updates about my blog. I have added a podcast feed from odiogo. So anybody interested to listen rather than read my post can download the podcast. Thats just another feature of this blog. Also i have included links from other blogs that i constantly read.These blogs cover lot of areas from business, technology, real estate and self-improvement. Just check them out. You might like a few of them.

Follow

Get every new post delivered to your Inbox.