Re: Need help to convert my C++ codes to Java with GUI



On Sat, 23 Feb 2008 20:46:10 -0800 (PST), Katak
<vampireex@xxxxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :

double exponent = Math.pow(2, power);
result += ((bin.charAt(i) - 48) * (exponent));
power++;

Shift would be more accurate and much much faster.

power = 1;
....
power <<= 1;

or even better just shift (bin.charAt(i) - '0') directly by i.

see http://mindprod.com/jgloss/shift.html
http://mindprod.com/jgloss/binary.html
http://mindprod.com/jgloss/precedence.html
http://mindprod.com/jgloss/bit.html
http://mindprod.com/jgloss/masking.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



Relevant Pages

  • Re: The 4e rules as a wargame
    ... to shift the Tarrasque as easily as a kobold. ... and certain terrain features are *bad* news (particularly in a new ... a relatively low level move power could be very bad news if there are ... "Shift other" is powerful. ...
    (rec.games.frp.dnd)
  • Re: The 4e rules as a wargame
    ... a move power should be able ... to shift the Tarrasque as easily as a kobold. ... skidding the tarrasque along until he's ... Starfire game and the arachnids where small craft swarms became the ...
    (rec.games.frp.dnd)
  • Re: The 4e rules as a wargame
    ... a move power should be able ... to shift the Tarrasque as easily as a kobold. ... skidding the tarrasque along until he's ... "Shift other" is powerful. ...
    (rec.games.frp.dnd)
  • Multi shift machine repair
    ... Last week we had a power outage on first shift that took down a Mori ... Power down, reset grid param, zero out, run tool changer, watch ...
    (alt.machines.cnc)
  • Re: She Lives !
    ... own power once again. ... Got a bit of adjusting to do on the shift and ... clutch rods, but that's gonna be easy compared to what I've done so far. ...
    (rec.motorcycles.harley)