good chemistry is complicated,and a little bit messy -LW PerlMonks

### comment on

 Need Help??
My method, first builds an approximation of the solution of a/b as...
```s1 = ((a / 2) / b) * 2;
a / 2 is done using the bug-free shift-right operator (>>) and results always in a number with bit 64 unset, so we can divide it by b without incurring in the convert-to-NV bug. Again multiplying by 2 is done with the shift-left operator (<<).

Then, we use the approximation to build the exact solution as:

```s = s1 + (a - s1 * b) / b

Well, actually, in order to do everything using bug-free operations, the code uses the following equivalence:

```s2 = (a / 2) / b
s1 = s2 * 2
s = s1 + (a - s1 * b) / b
s = s2 * 2 + (a - (s2 * b) * 2) / b
where \$d is s2, and \$e is (a - (s2 * b) * 2).

In reply to Re^3: 64-bit division anomolies (Solved.) by salva
in thread 64-bit division anomolies (Solved.) by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Are you posting in the right place? Check out Where do I post X? to know for sure.
• Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
• Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
• Want more info? How to link or How to display code and escape characters are good places to start.

Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2023-05-31 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found

Notices?