Article View: borland.public.cppbuilder.nativeapi
Article #5145Re: Another delphi translation please!
From: Bruce Knowles
Date: Mon, 26 Sep 2005 12:03
Date: Mon, 26 Sep 2005 12:03
70 lines
2683 bytes
2683 bytes
Hi,
There is a small error in the terms (b % 8)
Per the Delphi manual
div integer division integer integer Total div UnitSize
mod remainder integer integer Y mod 6
where
The value of x div y is the value of x/y rounded in the direction of zero to
the nearest integer.
The mod operator returns the remainder obtained by dividing its operands.
In other words, x mod y = x - (x div y) * y.
Or in otherwords.
Delphi -> C++
x mod y -> x % y
x div y -> (int) (x / y)
Regards
Bruce Knowles
"Andrue Cope [TeamB]" <no.spam@not.a.valid.address> wrote in message
news:4337b0dd$1@newsgroups.borland.com...
> Yike :)
>
> It would make life a little easier if you could un-nest the functions
> for us and personally I'm not sure what:
>
> Int64(RomCode) := 0;
>
> Is doing. Looks highly dubious but presumably TxRomCode is 4 bytes in
> size.
>
> Someone else might be willing to take it all on but for me on a Monday
> morning that's all a bit much but I'll have a stab at a bit of it:
>
> void SetSernumBit( int value,
> TxRomCode & RomCode, // Un-nesting
> int bitPos ) // Un-nesting
> {
> int b=bitPos-1;
>
> int i=b/8;
>
> if( value )
> RomCode[ i ]=RomCode[ i ]|( 1<<( b%8 ) );
> else
> RomCode[ i ]=RomCode[ i ]&( !( 1<<( b%8 ) ) );
> }
>
> BYTE GetSernumBit( TxRomCode & RomCode, // Un-nesting
> int bitPos ) // Un-nesting
> {
> int b=bitPos-1;
>
> int i=b/8;
>
> return RomCode[ i ]&( 1<<( b%8 ) );
> }
>
> --
> Andrue Cope [TeamB]
> [Bicester, Uk]
> http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<4337e343@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<43370a81@newsgroups.borland.com> <4337b0dd$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6ea8b2c4d2578842 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Bruce Knowles" <knowle_b@mtn.co.za> Newsgroups: borland.public.cppbuilder.nativeapi References: <43370a81@newsgroups.borland.com> <4337b0dd$1@newsgroups.borland.com> Subject: Re: Another delphi translation please! Date: Mon, 26 Sep 2005 14:03:36 +0200 Lines: 72 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 196.11.239.43 Message-ID: <4337e343@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1127736131 196.11.239.43 (26 Sep 2005 05:02:11 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail