halubilo.social
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@[email protected] to Programmer [email protected] • 8 days ago

parseInt(5)

lemmy.ml

message-square
63
fedilink
468

parseInt(5)

lemmy.ml

@[email protected] to Programmer [email protected] • 8 days ago
message-square
63
fedilink
  • @[email protected]
    link
    fedilink
    92•8 days ago

    It’s because parseInt is expecting a string, so the decimal gets converted to a string, and 0.0000005.toString() returns 5e-7.

    • @[email protected]
      link
      fedilink
      40•8 days ago

      Common Dynamic Typing L

      • @[email protected]
        link
        fedilink
        English
        4•8 days ago

        More like javascript L, even python would throw a TypeError for this example.

    • @[email protected]
      link
      fedilink
      29•
      edit-2
      8 days ago

      And to further expand on that, if you do pass in a sting string, it handles it correctly.

      > parseInt('0.0000005')
      
      0
      
      • @[email protected]
        link
        fedilink
        17•
        edit-2
        7 days ago

        What if I pass in a Stewart Copeland?

        • @[email protected]
          link
          fedilink
          9•8 days ago

          😆 I’ll be watching you…

        • Colonel Panic
          link
          fedilink
          3•8 days ago

          or a Honda civic

Programmer [email protected]

[email protected]

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]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
  • 732 users / day
  • 4.48K users / week
  • 8.43K users / month
  • 17.3K users / 6 months
  • 23.2K subscribers
  • 1.4K Posts
  • 50.6K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @[email protected]
  • Pierre-Yves Lapersonne
  • BE: 0.19.3
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org