There *was* a flaw in my program but not here. and when I found it I was a bit surprised by the compiler behavior.[/code]

Thu Nov 15, 2007 12:24 pm

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 615

Quote:

-100 is > than -90. Is this true in all languages?

I think it turned out that Chris was referring to ROBOTC's control of motors where positive numbers are forward direction and negative numbers are reverse. So of course a power level of -100 is faster (larger) than -90.

I can think of a couple of scenarios that would cause this. For exanple, if the declaration was

int rotation[1];
int i;

You would find that 'i' was overwritten by the assignment to 'rotation[i]' when 'i' is 1. If ROBOTC's array bounds checking was enabled this would be caught at run time.

Send me a compilable code snippet (at dickswan@sbcglobal.net) that illustrates only once through the loop and I will confirm and fix ROBOTC internal error if one exists.

Thu Nov 15, 2007 12:47 pm

elemes

Expert

Joined: Fri Nov 09, 2007 4:51 amPosts: 121Location: Hungary, Europe

Dick Swan wrote:

I think it turned out that Chris was referring to ROBOTC's control of motors

That's OK then.

My flaw (in the aboce example) was to declare i as a byte. I did not think RobotC follows the good old days of C when there was no type checking.

Here (I assume) the compiler casted the 500 to byte format. 500 is 0x1F4, chunking to 8 bits 0xF4 which is the binary representative of minus twelve (however, if the reasoning above is right, it is still interesting why the body of the "for" loop was executed even once. when, during troubleshooting, I replaced it with a "while" loop, it exited without executing the body).

Thu Nov 15, 2007 12:49 pm

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 615

Quote:

My flaw (in the above example) was to declare i as a byte. I did not think RobotC follows the good old days of C when there was no type checking.

This is not an "error" that is caught by any of the following commercial compilers -- Microsoft Visual Studio C++, IAR Embedded Workshop for ARM, MPLAB C18 compiler for Microchip or Renesas H8/300 -- that I just tried.

Unfortunately, this is valid C (and C++) syntax and semantics so type checking won't help. In C/C++ expressions are "promoted" to "int" precision during calculation.

IAR's C compiler and MS C++ (but not their C) compiler are the only two that generated warning messages for "i = 500;" where "i" is a char.

Thu Nov 15, 2007 8:41 pm

irenas1

Rookie

Joined: Thu Jun 06, 2013 2:12 amPosts: 1

Re: Best Programming Language for Lego Mindstorms, Hands Dow

There are some of the best Programming Language to learn like java, C++, PHP, visual basic. It's descriptions are available online.

_________________A.K.A. inxt-generationSelf-proclaimed genius, and future world dominator.My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth DoctorBow down to Nikola Tesla, King of the Geek Gods.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum