Campfyre
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
jroid8@lemmy.world to Programmer Humor@lemmy.ml · 2年前

know the features of your language

lemmy.world

message-square
144
fedilink
619

know the features of your language

lemmy.world

jroid8@lemmy.world to Programmer Humor@lemmy.ml · 2年前
message-square
144
fedilink
  • drolex@sopuli.xyz
    link
    fedilink
    arrow-up
    18
    arrow-down
    1
    ·
    2年前

    Loads of beginners in this thread. Here’s how it’s done in the industry.

    The code:

    return a;

    The test:

    a = rand()%100+1;

    It works, boss.

    • unalivejoy@lemm.ee
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      2
      ·
      edit-2
      2年前

      This must be a custom random function, because it’s standard for random to return a float between 0-1 exclusive. Maybe you meant to multiply by 100 instead of modulo.

      • drolex@sopuli.xyz
        link
        fedilink
        arrow-up
        11
        arrow-down
        1
        ·
        2年前

        I think for once I didn’t fuck up.

        https://cplusplus.com/reference/cstdlib/rand/

        • Snazz@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          2年前

          You guys are talking about two different things. Random integer vs random float

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 82 users / day
  • 819 users / week
  • 2.3K users / month
  • 6.59K users / 6 months
  • 2 local subscribers
  • 41.4K subscribers
  • 1.51K Posts
  • 36K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org