I would be very careful of using Decimal with anything, especially incrementing and decrementing them. You do realize that most implementation of 'decimal' are floats that are not accurate, and only intended to be used in engineering or scientific formulas that use a WIDE range of values? You especially never using floating-point for financial values.
I cant think of any instance where incrementing or decrementing a float will actually give you what you think it will give you. For example, if you have a float with a value of 10000.00, and you increment it by 0.10, you actually end up with 10000.099609. I'm sure thats not what you are after. What most people do, when they want exact numbers is to use an integer and then just manually apply the decimal point. To do this, assuming you only want two decimal places, you would actually store things multiplied by 100, and divide by 100 when you extract and want to display... Its a tad more complicated than that, but not by much, and hopefully you get the idea. In short... instead of storing 10000.00 in a float (or decimal or double), you instead store 1000000 in an integer (or long). So my question ends up being, why are you storing a decimal (float) value in memcache and why do you want to increment or decrement it? Dont believe me? Here is a little bit of C code to verify it... #include <stdio.h> > > int main(void) > { > float a, b; > > a = 10000.0; > b = a; > b += 0.1; > > printf("%f, %f\n", a, b); > > return 0; > } > > On Fri, Jun 27, 2008 at 5:18 PM, Vijay Mehta <[EMAIL PROTECTED]> wrote: > Hi Trond, > > Thanks for the reply. But can we have a feature request for incr/decr > decimal values ? > > Regards, > Vijay. > > > Trond Norbye wrote: > > > On Jun 27, 2008, at 9:55 AM, Vijay Mehta wrote: > > Hi @administrator, > > Need Help ! > Can anyone guide me if memcached supports incrementing/decrementing decimal > values. > > > It doesn't. > > See: > http://src.opensolaris.org/source/xref/webstack/memcached-incubator/trunk/server/doc/protocol.txt#286 > > The data for the item is treated as decimal representation of a 64-bit > unsigned integer. If the current data value does not conform to such a > representation, the commands behave as if the value were 0. > > > I have tried incrementing/decrementing - it only works for integers ! > > > That is correct. > > Trond > > -- "Be excellent to each other"