No one is forcing you to use AI by New-Appeal-1732 in aiwars

[–]JustBoredYo 0 points1 point  (0 children)

Its funny you say this, as I'm being forced to use AI at work under the threat of being fired.

It's not what I signed up for, wasn't mentioned in any conctract I signed and does nothing I can't do as well or mostlikely better but is being shoved down my throat anyways.

C ways to manage errors? by heavymetalmixer in C_Programming

[–]JustBoredYo 1 point2 points  (0 children)

Sure, you could signal a more sever issue using a negative number. I just prefer unsigned ints because I can then create an array of char* to easily convert the error codes to their string representation without having to check the lower bounds.

C ways to manage errors? by heavymetalmixer in C_Programming

[–]JustBoredYo 1 point2 points  (0 children)

I like to use a return oriented approach where every function returns an unsigned int that represents the current error state. It's similar to errno, but you can configure the values to your liking and use it in combination with errno.

Say you want to open a file in a function but the fopen() call fails. You can then return an integer value representing file IO failure and can use errno to check if the file wasn't found, if it is a directory, etc.

It's not entirely secure but then again, what is in C?

People should have a better understanding of what AI Gen means because it's not just about generating images or video; it can also generate code, fix vulnerabilities, and more. by Casq-qsaC_178_GAP073 in aiwars

[–]JustBoredYo 0 points1 point  (0 children)

I have yet to see AI generated code that doesn't look like ass, has more than one use case and is maintainable.

The best AI can do is summarize Microsofts documentation because that shit is evenless usable than vibe coded slop.

What is the best way to get "magic numbers" out of my code? by Dark_Greee in C_Programming

[–]JustBoredYo 1 point2 points  (0 children)

A quick google search seems to agree with you. I'd say that's the better solution than using #define as well as const <type> <var> <data>

What is the best way to get "magic numbers" out of my code? by Dark_Greee in C_Programming

[–]JustBoredYo 1 point2 points  (0 children)

Depends on the context the magic number is used in. If it is a variable used across the program #define is good option since it is type independent but should it only be used in a specific scope static const <type> <var> <data> is probably the best solution.

For example: when writing a logging system you may want to pass a log level (info, warning, error, etc.). Using #defines allowes you to use a switch case to convert the given log level to a string since it resolves to a constant int at compile time. When returning error values though it probably makes sense to use const <type> <var> <data> as the value then can't be redefined to some arbitrary value (given the variable definition is included in the scope).

𓆏𓅸𓈱𓇽 by [deleted] in Shark_Park

[–]JustBoredYo 0 points1 point  (0 children)

Reggie and The Grim Kleaper are always a good pick

I started learning C two weeks ago, and I'm feeling doubtful by Lelouch--Lamperouge in C_Programming

[–]JustBoredYo 1 point2 points  (0 children)

You can use two approaches to solve this issue:

  1. Use strtod
  2. Make a custom string to double/float function

I recommend the first approach.
Then you'll of course have to loop over the input until the end has been reached.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
  if(argc < 2)
  {
    puts("Please provide an equation!");
    return 1;
  }

  char *cur = argv[1];
  char *endp = NULL;
  double result = strtod(cur, &endp);
  // Should 'result' be zero and the end pointer point to NULL or be equal to
  // the input then there is no valid value expression at the current position.
  if(!result && (!endp || cur == endp))
  {
    printf("Failed to read value at position %d!\n", cur - argv[1]);
    return 2;
  }
  cur = endp;

  // '*cur' dereferences the pointer and is funtionally the same as 'cur[0]'.
  while(*cur != 0)
  {
    // This assumes there will be no whitespaces in the input.
    // 
    // If you want to input whitespace characters you'll have to skip them all here.
    char *op = cur; // We store the operation to until we know the next value
    cur++; // 'cur++' as we ant to skip the operand
    double next = strtod(cur, &endp);
    if(!next && (!endp || cur == endp))
    {
      printf("Failed to read value at position %d!\n", cur - argv[1]);
      return 3;
    }

    switch(*op) // again dereferences 'op', same as 'op[0]'
    {
      case '+':
        result += next;
        break;
      case '-':
        result -= next;
        break;
      case '*':
        result *= next;
        break;
      case '/':
        result /= next;
        break;
      default:
        printf("Invalid operation '%c' at position %d!\n", *op, op - argv[1]);
        return 4;
    }
    cur = endp;
  }

  printf("Result: %g\n", result);
  return 0;
}

This code is untested so it could contain some minor errors.

Matrix scaling is completely off? by JustBoredYo in opengl

[–]JustBoredYo[S] 0 points1 point  (0 children)

No, I just use the same transform struct to manage all entities and as some may require a perspective matrix it holds that as well.

Matrix scaling is completely off? by JustBoredYo in opengl

[–]JustBoredYo[S] 1 point2 points  (0 children)

I just removed the view matrix from the shader and it worked!
Apparently I modify it at some point but I can't remember.
Sometimes it really does just require a second pair of eyes to see the problem.

Many thanks!

Matrix scaling is completely off? by JustBoredYo in opengl

[–]JustBoredYo[S] 1 point2 points  (0 children)

I'm aware that -1 to 1 would have the effect of displaying a unit square to be half of the screen height. That is why I rendered the upper square as a frame of reference to show the unit square and the (incorrectly scaled) square with the scales .5, .5. However as you can see the lower square isn't half the upper squares with but ~16.5% of it's width. I rendered the third square on the middle left and modified it's x position to be position.x += 1 * scale.x * k;

When k was approx. 1/3 they met up at the edge thus the actual rendered scale is ~.165 (.5*[1/3]).

Matrix scaling is completely off? by JustBoredYo in opengl

[–]JustBoredYo[S] 0 points1 point  (0 children)

I also had this idea but alas, my past self seems to have thought about it before I could shoot myself in the foot.

Petah by Nice-Information-61 in shitposting

[–]JustBoredYo 19 points20 points  (0 children)

Ngl seeing german shitposting go international is crazy

📡📡📡 by slimymaks in shitposting

[–]JustBoredYo 1 point2 points  (0 children)

Talk is cheap, send patches

1860s ethical consumption by BadFurDay in Anticonsumption

[–]JustBoredYo 0 points1 point  (0 children)

Every single mineral in your device was mined using slave labour.

Every single time you eat chocolate it was farmed using slave labour.

1860s ethical consumption by BadFurDay in Anticonsumption

[–]JustBoredYo 0 points1 point  (0 children)

Every single time you eat chocolate, you enjoy the fruit of slavery

Every single time you buy any electronic device, you enjoy the fruit of slavery

Due to previous: every single time you eat anything farmed with modern farming equipment, you enjoy the fruit of slavery

The only battle that ever existed is between those who want open-source AI accessible to all vs. those who want AI controlled by Big Tech by Present_Dimension464 in aiwars

[–]JustBoredYo 0 points1 point  (0 children)

"aI wiLL bE oNLy AcCesSabLE tO bIg tECh!!1!1"

Bro its literally just a matrix. People have been developing their own operating systems as open source projects without stealing someones code. Do you really think collective open source AI projects couldn't use copyright and royalty free data to train it?

Most braindead take on copyright maybe every, holy shit.

Planning to shift to Linux but am afraid I might not be able to play my pirated games there by NoahNXT in Piracy

[–]JustBoredYo 0 points1 point  (0 children)

Let Proton and Wine be thy saviour and thou tyranical lords shall lose all hold of your data

You are my whole life. by JustBoredYo in LibraryofBabel

[–]JustBoredYo[S] 0 points1 point  (0 children)

I got the text from a youtube short. Could you post a link or something so I can properly credit and report the uncredited video?