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

know the features of your language

lemmy.world

message-square
145
fedilink
622

know the features of your language

lemmy.world

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

    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
      1 年前

      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
        ·
        1 年前

        I think for once I didn’t fuck up.

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

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

          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: !programmerhumor@lemmy.ml

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.

  • 20 users / day
  • 1.81K users / week
  • 2.61K users / month
  • 10.1K users / 6 months
  • 87 local subscribers
  • 35.7K subscribers
  • 1.7K Posts
  • 37K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • UI: 0.19.8
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org