本文整理汇总了C++中BigInteger类的典型用法代码示例。如果您正苦于以下问题:C++ BigInteger类的具体用法?C++ BigInteger怎么用?C++ BigInteger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BigInteger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTickSample
void setTickSample (void const* audioData, int dataBytes)
{
ScopedPointer <MemoryInputStream> mis (new MemoryInputStream (audioData, dataBytes, false));
m_synth.clearVoices ();
m_synth.clearSounds ();
AudioFormatManager afm;
afm.registerBasicFormats ();
{
ScopedPointer <AudioFormatReader> afr (afm.createReaderFor (mis));
if (afr != nullptr)
{
mis.release ();
BigInteger midiNotes;
midiNotes.setRange (0, 127, true);
SynthesiserSound::Ptr sound = new SamplerSound (
"Tick",
*afr,
midiNotes,
60,
0,
0,
60./40.);
m_synth.addSound (sound);
m_synth.addVoice (new SamplerVoice);
}
}
}
示例2: modExp
BigInteger BigInteger::modExp(const BigInteger &power, const BigInteger &modulo, const BigInteger &recip, short nb) const
{
BigInteger r;
BigNum::modExp(r, *this, power, modulo,recip,nb);
r.debugInitStr();
return r;
}
示例3: sub
BigInteger BigInteger::sub(const BigInteger &b) const
{
BigInteger r;
BigNum::sub(r, *this, b);
r.debugInitStr();
return r;
}
示例4: add
BigInteger operator - (BigInteger &in){
if(sign() != in.sign())
return add(*this, in, sign());
else if(compare(in, true) == LESS)
return sub(in, *this, in.sign());
else
return sub(*this, in, sign());
}
示例5: BigInteger
BigInteger *Pow(unsigned int x, unsigned int y){
BigInteger *output = new BigInteger(n_digits,x);
for(unsigned int i=2; i<=y; i++)
output->Multiply(x);
return output;
}
示例6: getNameForChannelPair
void OptionsDialog::updateOutputChannelComboBox()
{
m_ui->comboBox_OutputChannels->clear();
if ( isJackAudioEnabled() )
{
m_ui->comboBox_OutputChannels->setVisible( false );
m_ui->label_OutputChannels->setVisible( false );
}
else
{
m_ui->comboBox_OutputChannels->setVisible( true );
m_ui->label_OutputChannels->setVisible( true );
AudioIODevice* const currentAudioDevice = m_deviceManager.getCurrentAudioDevice();
if ( currentAudioDevice != NULL )
{
m_ui->comboBox_OutputChannels->setEnabled( true );
StringArray channelNames;
channelNames = currentAudioDevice->getOutputChannelNames();
StringArray channelPairNames;
for ( int i = 0; i < channelNames.size(); i += 2 )
{
const String& name = channelNames[i];
if ( i + 1 >= channelNames.size() )
channelPairNames.add( name.trim() );
else
channelPairNames.add( getNameForChannelPair( name, channelNames[i + 1] ) );
}
channelNames = channelPairNames;
int startBit;
const int numBits = 2;
const bool shouldBeSet = true;
for ( int i = 0; i < channelNames.size(); ++i )
{
// Each set bit represents an audio channel
startBit = i * 2;
BigInteger channels;
channels.setRange( startBit, numBits, shouldBeSet );
m_ui->comboBox_OutputChannels->addItem( channelNames[i].toRawUTF8(), channels.toInt64() );
}
}
else
{
m_ui->comboBox_OutputChannels->addItem( getNoDeviceString() );
m_ui->comboBox_OutputChannels->setEnabled( false );
}
}
}
示例7: inverseModN
BigInteger BigInteger::inverseModN(const BigInteger &n) const
{
BigInteger r;
BigNum::inverseModN(r,*this, n);
r.debugInitStr();
return r;
}
示例8: getActiveOutputChannels
BigInteger getActiveOutputChannels() const
{
BigInteger outputBits;
for (int i = 0; i < outputPorts.size(); i++)
if (juce::jack_port_connected ((jack_port_t*) outputPorts [i]))
outputBits.setBit (i);
return outputBits;
}
示例9: divBy
// q = this->divBy(divisor) is equilvalent to: q = this->quickDivMod(divisor,remainderResult); this = remainderResult;
BigInteger* BigInteger::divBy(const BigInteger* divisor, BigInteger* divResult)
{
BigInteger tempInt;
tempInt.setFromInteger(0);
quickDivMod(divisor, &tempInt, divResult); // this has been hard to get right. If bugs do show up,
//divResult = divideByReciprocalMethod(divisor,tempInt,divResult); // try this version instead Its slower, but less likely to be buggy
this->copyFrom(&tempInt);
return divResult;
}
示例10: getActiveInputChannels
const BigInteger getActiveInputChannels() const
{
BigInteger inputBits;
for (int i = 0; i < inputPorts.size(); i++)
if (JUCE_NAMESPACE::jack_port_connected ((jack_port_t*) inputPorts [i]))
inputBits.setBit (i);
return inputBits;
}
示例11: ALIASED
void
BigInteger::subtract(const BigInteger &a, const BigInteger &b)
{
ALIASED(this == &a || this == &b, add(a, b));
if (a.sign() == Zero) {
_mag = b._mag;
_sign = (b.sign() == Pos) ? Neg : (b.sign() == Zero) ? Zero : Pos;
} else if (b.sign() == Zero) {
*this = a;
} else if (a.sign() != b.sign()) {
_sign = a.sign();
_mag.add(a._mag, b._mag);
} else {
switch (a._mag.compareTo(b._mag)) {
case equal:
_mag = 0;
_sign = Zero;
break;
case greater:
_sign = a.sign();
_mag.subtract(a._mag, b._mag);
break;
case less:
_sign = (b.sign() == Pos) ? Neg : (b.sign() == Zero) ? Zero : Pos;
_mag.subtract(b._mag, a._mag);
break;
}
}
}// subtract
示例12: Test_BigMersennePrime
void Test_BigMersennePrime()
{
BigInteger mersenne (1);
BigInteger two (2);
for (int i = 0; i < 11213; i ++)
mersenne = mersenne * two;
mersenne = mersenne - 1;
cout << "Mersenne: " << endl << mersenne << endl;
cout << "Number of Digits: " << mersenne.Cardinality() << endl;
}
示例13: compare
int compare(BigInteger &in, bool abs) {
if(sign() != in.sign() && !abs)
return (sign())? GREATER : LESS;
if(size() != in.size())
return (size() > in.size())? GREATER : LESS;
for(int i=in.size()-1; i>=0; i--) {
if(value[i] == in.value[i])continue;
return (value[i] > in.value[i])? GREATER : LESS;
}
return EQUAL;
}
示例14: max
BigInteger operator-(BigInteger& x)
{
BigInteger res;
res.size = max(size,x.size) + 1;
for(int i = 0; i < res.size; i++)
res.M[i] = M[i] - x.M[i];
res.Normalize();
return res;
}
示例15: assert
BigInteger operator / (const BigInteger& b) const {
assert(b > 0); // 除数必须大于0
BigInteger c = *this; // 商:主要是让c.s和(*this).s的vector一样大
BigInteger m; // 余数:初始化为0
for (int i = s.size()-1; i >= 0; i--) {
m = m*BASE + s[i];
c.s[i] = bsearch(b, m);
m -= b*c.s[i];
}
return c.clean();
}