~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to ext/bigdecimal/bigdecimal.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-24 11:42:29 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080124114229-jw2f87rdxlq6gp11
Tags: 1.9.0.0-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Robustify check for target_os, fixing build failure on lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4318
4318
 
4319
4319
/*
4320
4320
 *
4321
 
 * f = 0: Round off/Truncate, 1: round up, 2:ceil, 3: floor, 4: Banker's rounding
4322
4321
 * nf: digit position for operation.
4323
4322
 *
4324
4323
 */
4339
4338
    nf += y->exponent*((int)BASE_FIG);
4340
4339
    exptoadd=0;
4341
4340
    if (nf < 0) {
 
4341
                /* rounding position too left(large). */
 
4342
                if((f!=VP_ROUND_CEIL) && (f!=VP_ROUND_FLOOR)) {
 
4343
                        VpSetZero(y,VpGetSign(y)); /* truncate everything */
 
4344
                        return 0;
 
4345
                }
4342
4346
        exptoadd = -nf;
4343
4347
        nf = 0;
4344
4348
    }
 
4349
 
4345
4350
    /* ix: x->fraq[ix] contains round position */
4346
4351
    ix = nf/(int)BASE_FIG;
4347
 
    if(((U_LONG)ix)>=y->Prec) return 0; /* Unable to round */
 
4352
    if(((U_LONG)ix)>=y->Prec) return 0;  /* rounding position too right(small). */
4348
4353
    ioffset = nf - ix*((int)BASE_FIG);
4349
4354
 
4350
4355
    v = y->frac[ix];
 
4356
 
4351
4357
    /* drop digits after pointed digit */
4352
4358
    n = BASE_FIG - ioffset - 1;
4353
4359
    for(shifter=1,i=0;i<n;++i) shifter *= 10;