[thelist] Just a quick WTF: How to cut off a number afteracertainamount of decimals

Luther, Ron Ron.Luther at hp.com
Tue Mar 28 13:55:00 CST 2006

Chris noted:
> I often encounter individuals who, when attempting to solve problems, 
> only ever consider solutions that they can implement with their 
> current knowledge base.

Sounds like another way to say "If all you have is a hammer ..."

And Matt Warden responded:
>>This might sound snide (not intended), but what else can one do? 
>>In this case, one would have to at least have the knowledge that 
>>exponentiation was a valid operation in the language (or that it 
>>was likely to be a valid operation). This knowledge is required 
>>for us to decide to put forth effort into research.

I agree with Matt, but I'd take it in a slightly different direction. 
I kinda see this as a two-step process; problem recognition and then 

The first part, recognizing that using exponentiation or modulo arithmetic 
or signum functions is a feasible solution to the problem at hand is the 
tough part.  It requires problem solving skills, pattern recognition 
skills and the experience to be able to apply them, sometimes in a new 
or slightly twisted way.  It's tough to teach creativity!

The second part, implementation, often comes down to syntax and with 
all the search engines and on-line resources available, that's 
easier today than it's ever been.  Of course, sometimes you need a 
deeper understanding of the technique in order to implement it if 
the tools at hand don't offer the shortcuts you are used to.  

[What's a shortcut?  How about Oracle's Trunc(x,y) function that 
will truncate any number 'x' to 'y' decimal places?  Doesn't get 
any easier than that!]   ;-)

But I think Chris' point may have been more of the ... if you work 
with a single tool long enough you become very familiar with it's 
limitations and develop 'blinders' to techniques you could use 
with other toolsets ... and I would tend to agree that is a danger.

My 2¢,


A lot of folks keep 'code snippets' or JS libraries of functions they 
have found useful in the past close at hand on a thumb drive or a CD 
or a personal web page for easy reference.  Add an index to that to 
jog your memory on the problem(s) they were used to solve and you 
have a personal 'knowledge base' or what I used to call a 
"bag o' tricks".  Keep adding to it when you come across 'neat stuff' 
and pretty soon you have a very useful reference.

More information about the thelist mailing list