Calculate PI To Arbitrary Precision (Sample Java Code)November 13th, 2007 Sample Java code to calculate PI to arbitrary precision. This uses Machin's formula: pi/4 = 4*arctan(1/5) - arctan(1/239).
JDK 1.6 Compiler Optimization performance difference between IP address to long implementationsAugust 5th, 2009 Just to give all ya techies some food for real geeky thoughts, here is a kind of an eye opener of how much JDK 1.6 compiler has optimized itself over the years. Our developers were working on a project that needed IP addresses to get simplified and be represented by numbers.
Java Software Programming Examples For Beginners / Interview: How To Swap Integer (and String) Variables Without Using a Temporary VariableOctober 29th, 2005 A Simple Programming Question for Beginners
JDK1.5 - Painful bugs: SolvedAugust 29th, 2004 Defects in early release of jdk.5 which have been solved.
HSQLDB Cached Table Versus Memory Table Performance & ConversionAugust 13th, 2007 In short in HSQLDB cached table sucks in terms of performance. To elaborate I was running a program which takes around 9 hours running on two medium sized cached tables (bigger one 163 MB).
Java Wins Programming Language of 2006 AwardJanuary 11th, 2006 Java has won the "TIOBE Programming Language of 2005" award. The Java language has increased its popularity in 2005 with 4.77%.
Java Continues As Leading Programming LanguageJune 6th, 2006 Java continues as the leading programming language according to TIOBE index updated on June 2006. Java is rated at 21.128%, an increase of 2.56% from June, 2005.
How To Debug Execution Path in PHP...Equivalent of printStackTrace() in JavaMarch 1st, 2007 While programming in PHP often you will find that a simple echo or log statement is not sufficient. You have found out where a problem is happening but you have no clue why it is executing that code in the first place.
Writing Comparator for sorting on columnsJanuary 25th, 2004 The challenge is to write a generic comparator which allows for sorting of the data based on a chosen column in either ascending or descending order when the column data type is not known upfront. When I faced with providing the ability to sort based on columns, I realized I had to implement a comparator which based on sorting criteria can sort in either ascending or descending order.
Analysis & Solution: Security Vulnerability Discovered in DWR, Open Source Java AJAX Development FrameworkJanuary 9th, 2007 Security vendor Imperva has identified an access-control vulnerability in DWR, Java Open Source AJAX development framework (stable release 1.1.3 and 2.0), which it says an attacker can use to compromise a DWR based application which may in turn enable him to say break into back-end databases or servers or launch a denial-of-service-attack. On a positive note Imperva commented that DWR, AJAX Web application development framework, is
"emerging as the lingua franca for building new generation Web 2.0 applications" :)
Forceful Method Invocation Attacks
The key issue is how DWR restricts access to not exposed class methods.
Contribute towards making a better JavaMay 14th, 2005 Do you know that now you too can contribute in developing the next version of Java - Mustang?
Here is your chance. What is Sun's motivation?
This definitely isn't about cost reduction.
Tips on Java Software Certification OptionsNovember 28th, 2005 I have received several questions regarding java certifications. This is a concise guide to java software certification options for java developers, software architects, non-developers like project managers, product managers etc.
Choosing Between Windows & Linux for Workstation & Servers: Rationale & ExperienceFebruary 17th, 2007 Traditionally companies choose Windows as their desktop environment and often for their intranet servers too. Windows is generally perceived as being easier to use and administer and mostly with good reason.
Experiences & Insights in Adopting Agile Development Methodology in CorporationsNovember 2nd, 2007 Recently Andrea Tringo posted in Sun Alumni mailing list asking questions in every executive's mind who wants to adopt agile development methodology (like XP) but do not know how to proceed safely. Andrea asked:
I know a lot of tech companies are enthusiastically adopting Agile, as many of us embrace(d) Six Sigma, among other practices.
How ___ to develop great software: A GuideApril 1st, 2005 A guide to software nirvana.
January 25th, 2004 at 6:16 am
Hmm. Did a search and found this. http://mindprod.com/jgloss/widthindigits.html
If you are strictly dealing with ints, it seems like this method is the most optimized as it doesn’t require any method calls or logorithmic computation. It performs at most 3 simple comparisons.
/**
* Counts number decimal digits in a 32 bit signed number. 0 => 1, 9 => 1,
* 99 => 2, 2,147,483,647 => 10
*
* @param x
* number whose digits you wish to count. Must lie in range 0 ..
* Integer.MAX_VALUE;
*
* @return number of digits in x, e.g. Integer.toString(x).length()
* @author Marc Chappuis marnic@ludomedia.ch
*/
public static int widthInDigits(int x) {
// do an unravelled binary search
if (x
April 27th, 2009 at 8:06 am
int n = 12345;
String s = String.valueOf(n);
int counted = s.length();
July 23rd, 2009 at 8:53 pm
@Min the issue with this approach is you have to explicitly set the bounds. This is fine for base 10, but what about base 2? One can represent a pretty long binary number in a “long” datatype.
@Absar String operations are much expensive than numerical operations. Also, this does not take into account other bases (though it could, by using a STRING->NBASE function).
September 17th, 2009 at 1:09 am
It doesnt seem to work when I enter a 7 digit number, I get a cound of 6.
It works on 6 digits and 8 digits but not 7. Probably more errors with other values as well..