QIF Import fails out of CVS

Derek Atkins warlord@MIT.EDU
13 Feb 2001 16:35:37 -0500


This is definitely a problem with logand, but moreso it a problem with
how we're using it.  Converting parts gnc_scm_to_gint64(SCM num) to
scheme code directly show the problem quite clearly:

gnc_scm_to_gint64(SCM num)	/* In part, from gnc-helpers.c */
{
  SCM bits00to15_mask = gh_ulong2scm(0xFFFF);
  SCM magnitude  = scm_abs(num);
  SCM bits00to15 = magnitude;
  unsigned long c_bits00to15=0;

  c_bits00to15 = gh_scm2ulong(scm_logand(bits00to15, bits00to15_mask));
}

Converting this to scheme, step-by-step, assuming some value for num:

guile> (define num 12345678901234567890)
guile> (define mask 65535)
guile> (define mag (abs num))
guile> (logand mag mask)
ERROR: In procedure logand in expression (logand mag mask):
ERROR: Wrong type argument in position 1: 12345678901234567890
ABORT: (wrong-type-arg)

;; Note that -62 is the value of SCM_MAKINUM(-16)
guile> (logand (ash mag -62) mask)
2
guile> (ash mag -62)
2

I'm not sure what "ash" does precisely.  Even the C code is a bit
obfuscated.  However, even if we used SCM_MAKINUM(0) (==2) for the
first one:

guile> (logand (ash mag 2) mask)
ERROR: In procedure logand in expression (logand (ash mag 2) mask):
ERROR: Wrong type argument in position 1: 49382715604938271560
ABORT: (wrong-type-arg)

But this is definitely where the problem is.  I clearly don't
understand how gnc_scm_to_gint64(SCM num) is trying to convert the
number from scheme to C..

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available