exponentiate, exponentiate and assign

Forum for discussion about the documentation project.
Post Reply
thacket
Posts: 7
Joined: Sep 21, 2012 20:32

exponentiate, exponentiate and assign

Post by thacket »

Hello to All,

I am not where to put this but I am translating some code from 'C' to 'FreeBasic'. Without going into detail, I had a couple of frustrating minute before I snapped to the problem:

Language Operator Function Label
C ^= XX ^= YY is XX = XX ^ YY is XX = (XX XOR YY) Bitwise XOR assignment
FreeBasic ^= XX ^= YY is XX = XX raised to the power of YY Exponentiate and assign

I am assuming there are a couple of other gotchas as well. I really like FreeBasic; is there a way to add something like this to the documentation? Also for the '^' operator documentation? Thanks for your time.

All the Best,
John
thacket
Posts: 7
Joined: Sep 21, 2012 20:32

Re: exponentiate, exponentiate and assign

Post by thacket »

Let me try this again:

Code: Select all

Language    Operator    Function                                                  Label

    C          ^=       XX ^= YY   is   XX = XX ^ YY   is   XX = (XX XOR YY)      Bitwise XOR assignment
FreeBasic      ^=       XX ^= YY   is   XX = XX raised to the power of YY         Exponentiate and assign
I hope this is a little clearer. Thanks for your patience.

All the Best,
John
codeFoil
Posts: 256
Joined: Dec 22, 2011 4:45
Location: United States
Contact:

Re: exponentiate, exponentiate and assign

Post by codeFoil »

Logical operators and operators for exponents and remainders are the most common differences between programming language families. When you're porting from one to another, it's a good idea to just keep the list of operators and their precedence handy. Check the wiki for the operator precedence page. All the operator are there.

In BASIC, arithmetic is usually performed with symbols (except mod), and logical and bitwise operations use keywords.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: exponentiate, exponentiate and assign

Post by counting_pine »

I suppose another Gotcha might be & and &= which perform concatenation instead of bitwise AND.
The pages for these operations can be found in wiki form where they can be edited. e.g. KeyPgOpConcatConvert
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: exponentiate, exponentiate and assign

Post by counting_pine »

TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: exponentiate, exponentiate and assign

Post by TJF »

counting_pine wrote:OK, I've added a note to these pages:
KeyPgOpExponentiate
KeyPgOpCombineExponentiate
KeyPgOpConcatConvert
KeyPgOpCombineConcat
Shall we really document C / C++ syntax in FreeBasic keyword Wiki pages? (It may confuse beginners.)

I think it's good to document syntax differences to get new translators started, but this shouldn't be done in an extra section.
thacket
Posts: 7
Joined: Sep 21, 2012 20:32

Re: exponentiate, exponentiate and assign

Post by thacket »

Hello,

Thanks for the added notes on these operators; Not too verbose and not too sparse. In my opinion, a one or two sentence note is just right. If I run into other ones like that, I will let you know. I have no doubt that some definitions should not be modified. Take care.

All the Best,
John
Post Reply