« Programmation Java/Nombre de taille arbitraire » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 51 :
 
{| class="wikitable"
|+ Méthodes pour les opérateurs arithmétiques
|+ <syntaxhighlight lang="java" inline>BigInteger a.</syntaxhighlight>
! Opérateur équivalent
|+! <syntaxhighlight lang="java" inline>BigInteger a.</syntaxhighlight>
! Méthode
! Description
|-
| style="text-align:center;" | <code>-</code> || negate()
| Retourne le résultat de l'inversion de signe <syntaxhighlight lang="java" inline>-a</syntaxhighlight>
|-
| style="text-align:center;" | <code>+</code> || add(BigInteger b)
Ligne 87 ⟶ 90 :
BigInteger d = a.add(b).multiply(c).divide(BigInteger.TEN);
</syntaxhighlight>
 
 
{| class="wikitable"
|+ Méthodes pour les opérateurs sur les bits
! Opérateur équivalent
! <syntaxhighlight lang="java" inline>BigInteger a.</syntaxhighlight>
! Description
|-
| style="text-align:center;" | <code>~</code> || not()
| Retourne le résultat de l'inversion de bits <syntaxhighlight lang="java" inline>~a</syntaxhighlight>
|-
| style="text-align:center;" | <code>&</code> || and(BigInteger b)
| Retourne le résultat du et bit à bit <syntaxhighlight lang="java" inline>a & b</syntaxhighlight>
|-
| style="text-align:center;" | <code>& ~</code> || andNot(BigInteger b)
| Retourne le résultat du et bit à bit avec inversion <syntaxhighlight lang="java" inline>a & ~b</syntaxhighlight>.
 
Cette méthode est un raccourci pour la combinaison des opérateurs <code>&</code> et <code>~</code> pour le masquage de bits.
|-
| style="text-align:center;" | <code>|</code> || or(BigInteger b)
| Retourne le résultat du ou bit à bit <syntaxhighlight lang="java" inline>a | b</syntaxhighlight>
|-
| style="text-align:center;" | <code>^</code> || xor(BigInteger b)
| Retourne le résultat du ou exclusif bit à bit <syntaxhighlight lang="java" inline>a ^ b</syntaxhighlight>
|}
 
== Nombre décimal ==