## Search found 16 matches

- Thu Jun 25, 2009 3:07 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

I was simply trying to dispute the notion that BCD must be chosen because of performance reasons. Which isn't actually a claim I ever made. Or at least, not one I meant to, I may have worded things badly. My point was always that you couldn't use native integers anyway, so with BCD you had a wider ...

- Wed Jun 24, 2009 7:49 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

Dave, I suspect we may be in violent agreement here. Obviously BCD doesn't imply bignums, it's just an encoding. You can pack it two to a byte or not, that's not required either. But 32 bits just isn't big enough regardless --- they're fast but it doesn't matter ---so yes you're into bignum territor...

- Wed Jun 24, 2009 3:12 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

I can't think of a reason why you would prefer BCD over pure binary integers.... I wasn't as clear as I should have been, relying on the context of the rest of the thread. My commentary was also more general than lisp specific... If you are doing serious accounting computations, you don't want to u...

- Tue Jun 23, 2009 4:25 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

In case anyone is at all confused about this, I should note I really don't recommend using floats for currency computations, for several reasons. I just think if you're going to reject something, you should reject it for the right reasons, and not propagate more misunderstandings. I was also noting ...

- Tue Jun 23, 2009 4:12 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

If you must store money with a binary type, its probably better to store integers representing cents (or tenths or hundredths of a cent -- i.e. fixed-point) than to store doubles representing dollars. For addition and subtraction, it doesn't matter; but for multiplication (interest, taxes, etc), pr...

- Tue Jun 23, 2009 4:07 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

By representable range you mean a bit less than (* 1d-2 (/ long-float-epsilon)), right? The whole deal with "never use floating point for financial computations" is that money violates the pretty fundamental assumption of floating point values, that we don't care about numbers sufficiently smaller ...

- Mon Jun 22, 2009 10:04 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

Which is why it often is a good idea to use floats...use them as 53 bit hardware-supported big-fixnums... Paul is quite right, the "never use floating point for financial computations" idea is overly stated. Floats are perfectly accurate and fast for integer and decimal computations like this so lo...

- Thu Jun 18, 2009 9:43 pm
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies:
**28** - Views:
**15946**

### Re: incorrect simple floating point math

Wow... is this how most programmers program mathematically when using numbers with decimal points? If not, how does one generally program with mathematical accuracy? I've been reading links for a while and it seems like there isn't an easy solution to doing accurate math. Maybe Vedic Mathematics? ;...

- Wed Jun 17, 2009 10:08 am
- Forum: Common Lisp
- Topic: Copying a multidimensional array
- Replies:
**10** - Views:
**5297**

### Re: Copying a multidimensional array

It won't make a transient copy of the actual data, but it will create a small "displaced array object" ... This was my initial thought as well, but without consulting the spec I didn't want to commit to "never copying". On reflection, I can't see a way this could run into trouble but I didn't stop ...

- Tue Jun 16, 2009 10:58 pm
- Forum: Common Lisp
- Topic: Coercing to double-float
- Replies:
**4** - Views:
**2910**

### Re: Coercing to double-float

Sorry. (coerce .2 'double-float) produces 0.20000000298023224d0 (* .2 1d0) produces 0.20000000298023224d0 (* .2d0 .1d0) produces 0.020000000000000004d0 I think I will just stick to the float version of the c library. Thanks for the explanation! Huh, strange that I completely missed your typo earlie...