 
         do
         {
-            addIonsAB(b_mass, charge, spec);
-            addIonsY (y_mass, charge, spec);
+            addIonsAB(b_mass, (float) charge, spec);
+            addIonsY (y_mass, (float) charge, spec);
         }
         while (++charge < max_charge);
     }



/*
 * Convert a given mass into a mass/charge ratio, and locate the appropriate
 * spectrum bin for the peak.
 */
__device__ int
binIonMZ(float mass, int charge)
{
    int bin = rintf((mass + massH * charge) / (charge * binWidthMono));
#ifdef __DEVICE_EMULATION__
    assert(bin >= 0 && bin < 2048);
#endif
    return bin;
}


/*

 * corresponding to the neutral losses of H2O and NH3.
 */
__device__ void
addIonsAB(float mass, float charge, int *spec)
{
    // A
    atomicMax(&spec[bin(ionMZ(mass - massCO, charge))], 10);

    // B
    float m = ionMZ(mass, charge);
    int   b = bin(m);

    atomicMax(&spec[b],   50);
    atomicMax(&spec[b+1], 25);
    atomicMax(&spec[b-1], 25);
    atomicMax(&spec[bin(m - massH2O/charge)], 10);
    atomicMax(&spec[bin(m - massNH3/charge)], 10);
}


__device__ void
addIonsY(float mass, float charge, int *spec)
{
    float m = ionMZ(mass + massH2O, charge);
    int   b = bin(m);

    atomicMax(&spec[b],   50);
    atomicMax(&spec[b+1], 25);
    atomicMax(&spec[b-1], 25);
    atomicMax(&spec[bin(m - massNH3/charge)], 10);
}


