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

parseInt(5)

lemmy.ml

message-square
63
fedilink
474

parseInt(5)

lemmy.ml

@[email protected] to Programmer [email protected] • 1 year ago
message-square
63
fedilink
  • @[email protected]
    link
    fedilink
    94•1 year 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•1 year ago

      Common Dynamic Typing L

      • @[email protected]
        link
        fedilink
        English
        4•1 year ago

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

    • @[email protected]
      link
      fedilink
      29•
      edit-2
      1 year 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
        1 year ago

        What if I pass in a Stewart Copeland?

        • @[email protected]
          link
          fedilink
          9•1 year ago

          😆 I’ll be watching you…

        • Colonel Panic
          link
          fedilink
          3•1 year 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
  • 740 users / day
  • 3.22K users / week
  • 7.04K users / month
  • 17.2K users / 6 months
  • 33.2K subscribers
  • 2.53K Posts
  • 94.9K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @[email protected]
  • Pierre-Yves Lapersonne
  • BE: 0.19.3
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org