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

parseInt(5)

lemmy.ml

message-square
63
fedilink
472

parseInt(5)

lemmy.ml

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

      Common Dynamic Typing L

      • @[email protected]
        link
        fedilink
        English
        4•2 months ago

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

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

        What if I pass in a Stewart Copeland?

        • @[email protected]
          link
          fedilink
          9•2 months ago

          😆 I’ll be watching you…

        • Colonel Panic
          link
          fedilink
          3•2 months 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
  • 1.46K users / day
  • 2.75K users / week
  • 9.17K users / month
  • 19K users / 6 months
  • 24.5K subscribers
  • 1.53K Posts
  • 54.9K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @[email protected]
  • Pierre-Yves Lapersonne
  • BE: 0.19.3
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org