Thread: What is wrong my algorithm i ask here becouse i give formula in C ?

  1. #1
    Registered User
    Join Date
    Dec 2013
    Posts
    46

    What is wrong my algorithm i ask here becouse i give formula in C ?

    What is wrong m algorithm i ask here becouse i give formula in C ?
    (x + y % 2) *255
    i read this way when x and y are both odd or even code gives 255
    but if one is odd and one is even i get 0.
    how i must modify this to get it working way what i mean. i try make quick algorithm which gives part of checkerboard using given x and y coordinate. in theory when i get it work i can do bigger broads diving x and y using some number...

  2. #2
    Registered User
    Join Date
    Dec 2014
    Posts
    1
    I'm a tad bit confused on what you're trying to ask. I'm new here, but could you please show your code?

  3. #3
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    Modulo has a higher binding then addition. Your Formula will calculate in this way:
    Code:
    (x + (y % 2)) * 255
    If you want that the formula give you the expected result, you should edit the formula like this:
    Code:
    ((x + y) % 2) * 255
    Other have classes, we are class

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    2
    Hi just remember like the "Please Excuse My Dear Aunt Sally" paren, expon, mult,div, add sub, modulo is like division.

  5. #5
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    Quote Originally Posted by Mathacka View Post
    Hi just remember like the "Please Excuse My Dear Aunt Sally" paren, expon, mult,div, add sub, modulo is like division.
    I try but now this dont work way what expect area is arraged alpha,red,green,blue ja again sama etc... and what i expect black white checkerboard.
    [C] Non wokring checkerboard - Pastebin.com

  6. #6
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    Are you really sure that the datas are arranged in ARGB? Normaly, the datas in an 32bit image are arranged in the order RGBA.
    Other have classes, we are class

  7. #7
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    Quote Originally Posted by WoodSTokk View Post
    Are you really sure that the datas are arranged in ARGB? Normaly, the datas in an 32bit image are arranged in the order RGBA.
    problem what i haveis nothing do with this. I try get pic of result.
    and these platforms use PowerPC and some even motorla 68000 series (for example 68060).

  8. #8
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    Quote Originally Posted by Vanhapolle View Post
    problem what i haveis nothing do with this. I try get pic of result.
    and these platforms use PowerPC and some even motorla 68000 series (for example 68060).
    there is pic which shows using yellow and black (dont care gray background) what is wrong still. variable type can store here
    which nothing ischanged 32bit non signed values which i earlier thinked ansver
    but looks it not. ANother solution is made code which i still
    understand which adds x and y. and checks lowest bitvalue
    becouse its then tells its number evenor odd. but such ..........ecks must be learned then.
    https://www.flickr.com/photos/65552520@N07/15976327250/

  9. #9
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    Your formula calculate how many bytes you must seek in the picture for pptry.
    At the end, you add pprtx to the result, this is wrong.
    You must also multiply pptrx with bytesperpixel!

    Test this formula:
    Code:
    pptr = (pptrx + pptry * image_w) * bytesperpixel;
    Other have classes, we are class

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Give Error Message If User Inputs Wrong
    By Aliano in forum C Programming
    Replies: 6
    Last Post: 11-04-2013, 11:48 AM
  2. Would this formula give me The GPA of a list of numbers
    By artistunknown in forum C Programming
    Replies: 23
    Last Post: 10-12-2013, 05:58 PM
  3. Always give me wrong answer
    By amroto in forum C Programming
    Replies: 8
    Last Post: 03-29-2012, 09:43 AM
  4. What's wrong with STL rotate algorithm?
    By Mathsniper in forum C++ Programming
    Replies: 3
    Last Post: 12-09-2006, 08:54 AM
  5. please give me the algorithm or pseudocode
    By nesir in forum C Programming
    Replies: 19
    Last Post: 08-05-2006, 08:07 AM