W3C home > Mailing lists > Public > www-style@w3.org > July 1997

Re: Negative margins

From: David Perrell <davidp@earthlink.net>
Date: Mon, 21 Jul 1997 19:19:03 -0700
Message-Id: <199707220228.TAA07049@germany.it.earthlink.net>
To: <www-style@w3.org>, "Sho Kuwamoto" <skuwamoto@macromedia.com>
Sho Kuwamoto wrote:
> So, combining (1.2) and (2.2), the algorithm to compute the
> space between block-level elements would be:
> 
> if (a >= 0 && b>= 0)
> 	space = max(a,b);
> 
> else if ( (a >= 0 && b < 0) || (a < 0 && b >= 0) )
> 	space = a+b;
> 
> else // a < 0 && b < 0
> 	space = -max(-a,-b);
> 
> Any thoughts?

Well, if you're doing it in 32-bit x86 assembler, I think this will do
the job quite quickly:

   mov   eax,margin1
   mov   ebx,margin2
   cmp   eax,ebx
   jg    greaterax
   xchg  eax,ebx
   jbe   switcheck
addem:
   add   eax,ebx
   jmp   done
greaterax:
   jb    addem
switcheck:
   or    eax,eax
   jns   done
   xchg  eax,ebx
done:
                  ; eax now has margin

David Perrell
Received on Monday, 21 July 1997 22:28:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:50 GMT