Talk:Generalised floating point addition: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
Line 32: Line 32:
[[User:NevilleDNZ|NevilleDNZ]] 08:45, 30 October 2011 (UTC)
[[User:NevilleDNZ|NevilleDNZ]] 08:45, 30 October 2011 (UTC)


: Yes? I am being lazy here, and asking for a clarification of the task. And, since no sequence was defined, I am being too lazy to derive the sequence for myself. I am also ignoring most of the details of the task -- I am, in fact, not using "floating point" at all here, except as a notation (and that only loosely). That said, I am confident that my implementation will have significantly better performance than BCD for these calculations -- the BCD implementation multiplies by 81 using 81 successive additions where my I am just multiplying. That said, performance is generally something we try and ignore on this site (except where it gets in the way). --[[User:Rdm|Rdm]] 09:07, 30 October 2011 (UTC)
: Yes? I am being lazy here, and asking for a clarification of the task. And, since no sequence was defined, I am being too lazy to derive the sequence for myself. I am also ignoring most of the details of the task -- I am, in fact, not using "floating point" at all here, except as a notation (and that only loosely). That said, I am confident that my implementation will have significantly better performance than BCD for these calculations -- the BCD implementation multiplies by 81 using 81 successive additions where I am just multiplying. That said, performance is generally something we try and ignore on this site (except where it gets in the way). --[[User:Rdm|Rdm]] 09:07, 30 October 2011 (UTC)

Revision as of 09:07, 30 October 2011

Clarify?

I have a few questions:

  1. Why?
  2. A floating point number involves three integers: the significand, the base and the exponent. Wouldn't it be more of a hoot to allow them to be in different bases?
  3. Suppose I want to compute a + b. Is it acceptible to first convert them into machine native format, add up, then convert back to whatever base they were in? Could a and b be in different bases to begin with? --Ledrug 16:52, 28 October 2011 (UTC)

1. re: Why?

This pattern (or subsets of this pattern) happen often enough that it is worth implementing it in general. Hence the emphasis on a "Mixin" or Template" solution. More generally the "DIGITS" are not specifically numerical, they only require a "+" operation, a digit index, MSD, LSD and the concept of ZERO.

2. re: ... allow them to be in different bases?

That would depend on a natural example of the significand, the base and the exponent in different bases. IEEE_754 Basic_formats has Decimal128 floating-point format appears to be an example BCD significand and "modified" Binary exponent. /* I'm guessing that this is because the input and output data are decimal */. But your suggestion is reasonably close and if it can be implemented reasonably cleanly then it would probably fit the Rosettacode's spirit of "codifying your suggestion". The one thing I love about Rosettacode is the surprises that emanate from other languages and other interpretations.

3. re: ... Is it acceptible to first convert them into machine native format.

I saw this more as a Templating and significand "list processing" "algorithm" definition task. /* Esp as the "DIGITS" may not even be numerical. */ So my preference is to avoid normalising to a canonical form based on a specific hardware implementation. [ If you know what I mean... I can almost say that last paragraph in one breath... :-) ]

NevilleDNZ 11:10, 29 October 2011 (UTC)

Repeating the "why"?

I have posted an implementation of J, based on the answer given here for "why" (ignoring concepts that seem unnecessary and focusing on the desired result). I believe that this implementation is convenient to use, fast to implement, and that it performs reasonably well. Is this an acceptable implementation? If so, could the task description be changed to allow it? If not, perhaps you could expand on the "why" to explain why I need to do something different? Thanks! --Rdm 08:22, 30 October 2011 (UTC)

The task requires "Calculate the terms for -8 to 20 in this sequence". I notice J only got as far as -4. Most programming languages are constrained by their hardware floating point. Maybe J isn't, but most are. Hence the need for a Template/Library in these less advanced languages.

> More generally the "DIGITS" are not specifically numerical, they only require a "+" operation, a digit index, MSD, LSD and the concept of ZERO.

IEEE has Decimal128 floating-point format in BCD for just this reason. In this case BCD is used where performance and/or accuracy is required.

NevilleDNZ 08:45, 30 October 2011 (UTC)

Yes? I am being lazy here, and asking for a clarification of the task. And, since no sequence was defined, I am being too lazy to derive the sequence for myself. I am also ignoring most of the details of the task -- I am, in fact, not using "floating point" at all here, except as a notation (and that only loosely). That said, I am confident that my implementation will have significantly better performance than BCD for these calculations -- the BCD implementation multiplies by 81 using 81 successive additions where I am just multiplying. That said, performance is generally something we try and ignore on this site (except where it gets in the way). --Rdm 09:07, 30 October 2011 (UTC)