Jump to content

8 posts in this topic

Recommended Posts

Posted

Given two double values double1 , double2, why isn’t it reliable to test their equality using:

double1 == double2;

???

Comment possible code below!!

If you are the first person to get this I will follow you!!

 

HINT:

Spoiler

If both doubles are assigned NaN  (not a number) it returns false! 

How could you COMPARE the two values against a real number (zero)

 

Posted (edited)
1 hour ago, LifeElevated said:

How could you COMPARE the two values against a real number (zero)

Can you specify it?... I dont understand

is it this?

Double.compare(double1,double2) == 0);

Updated by FinnLord
Posted
18 hours ago, FinnLord said:

Can you specify it?... I dont understand

is it this?

Double.compare(double1,double2) == 0);

Yes this is the right answer. Now tell us why (==) isn't efficient to compare double variables?

Posted
On 5/18/2018 at 12:21 AM, LifeElevated said:

Honestly this is worded to weird ?

Its not. I joined this club so i could respond

 

If you have a double or a float in any language, you can't expect them to be completely precise. For example, if you have two doubles 

double num1 = 3.0;
double num2 = 3.0;

It looks like they should be equal, right? But they most likely aren't. why? because  floats and doubles are very precise. Here's what num1 and num2 really are:

num1: 3.00000000000000000000000000000000382918
num2: 3.00000000000000000000000000000000261527

So that's why you can't compare doubles and floats with the == operator in any language really. Here's some code to correctly compare floats in c++

bool cmpf(float a, float b){
	return (fabs(a - b) < 0.005f);
}

I guess in Java it would be something ridiculous like

static boolean cmpf(double a, double b){
	return (Math.abs(a - b) < 0.005);
}

I f***ing hate java

  • Our picks

    • Royal Kingdom v19683 +4 Jailed Cheats [ Coins + More ]
      Modded/Hacked App: Royal Kingdom By Dream Games
      Bundle ID: com.dreamgames.royalkingdom
      iTunes Store Link: https://apps.apple.com/ph/app/royal-kingdom/id1606549505
       

      Hack Features:
      - Freeze Coins
      - Freeze Lives
      - Freeze Boosters
      - Freeze Moves


      Jailbreak required hack(s): [Mod Menu Hack] Royal Kingdom v3987 +4 Cheats [ Unlimited Coins ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 137 replies
    • Royal Kingdom v19683 +4 Cheats [ Coins + More ]
      Modded/Hacked App: Royal Kingdom By Dream Games
      Bundle ID: com.dreamgames.royalkingdom
      iTunes Store Link: https://apps.apple.com/ph/app/royal-kingdom/id1606549505
       

      Hack Features:
      - Freeze Coins
      - Freeze Lives
      - Freeze Boosters
      - Freeze Moves


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Royal Kingdom v3987 +4 Jailed Cheats [ Unlimited Coins ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 88 replies
    • League of Dreamers - My Story v2.1.4 +3 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: League of Dreamers - My Story By Story Inc. Company
      Bundle ID: com.storyincorporate.leagueofdreamers
      iTunes Store Link: https://apps.apple.com/us/app/league-of-dreamers-my-story/id1591679538
       

      Hack Features:
      - 666 Gems -> Earn some then restart the game.
      - 666 Keys -> Earn some then restart the game.
      - Free In-App Purchases -> Allows free in-app purchases.


      Jailbreak required hack(s): [Mod Menu Hack] League of Dreamers - My Story v1.54 +3 Cheats [ Unlimited Currencies ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Like
      • 172 replies
    • League of Dreamers - My Story v2.1.4 +3 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: League of Dreamers - My Story By Story Inc. Company
      Bundle ID: com.storyincorporate.leagueofdreamers
      iTunes Store Link: https://apps.apple.com/us/app/league-of-dreamers-my-story/id1591679538
       

      Hack Features:
      - 666 Gems -> Earn some then restart the game.
      - 666 Keys -> Earn some then restart the game.
      - Free In-App Purchases


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Like
      • 81 replies
    • Power Slap v7.2.6 +2++ Jailed Cheats [ Unlimited Everything ]
      Modded/Hacked App: Power Slap By Rollic Games Oyun Yazilim ve Pazarlama Anonim Sirketi
      Bundle ID: com.uncosoft.powerslap
      iTunes Store Link: https://apps.apple.com/us/app/power-slap/id6449244841?uo=4


      Hack Features:
      - Unlimited Everything -> Will increase instead of decrease.
      - Pro Pass Unlocked


      Jailbreak required hack(s): [Mod Menu Hack] Power Slap v0.4.1 +4 Cheats [ Damage & Defence ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 160 replies
    • Idle Breaker v1.4.0 +5++ Jailed Cheats [ Unlimited Everything ]
      Modded/Hacked App: Idle Breaker By Estoty LLC
      Bundle ID: com.idlesurvivor.game
      iTunes Store Link: https://apps.apple.com/us/app/idle-breaker/id6448195469?uo=4


      Hack Features:
      - Unlimited Everything -> Earn some.
      - Damage Multiplier
      - Health Multiplier
      - Tool Damage Multiplier
      - Move Speed Multiplier


      Jailbreak required hack(s): [Mod Menu Hack] Idle Breaker v1.0.31 +5++ Cheats [ Unlimited Everything ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 58 replies
    • Power Slap v7.2.6 +2++ Cheats [ Unlimited Everything ]
      Modded/Hacked App: Power Slap By Rollic Games Oyun Yazilim ve Pazarlama Anonim Sirketi
      Bundle ID: com.uncosoft.powerslap
      iTunes Store Link: https://apps.apple.com/us/app/power-slap/id6449244841?uo=4


      Hack Features:
      - Unlimited Everything -> Will increase instead of decrease.
      - Pro Pass Unlocked


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Power Slap v0.4.1 +2 Jailed Cheats [ Unlimited Currencies ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 113 replies
    • Slime Legion v3.3.0 +3 Jailed Cheats [ Damage & Defence ]
      Modded/Hacked App: Slime Legion By Perfeggs
      Bundle ID: com.hero.may.cry.adventure.game
      iTunes Store Link: https://apps.apple.com/us/app/slime-legion/id1664686966
       

      Mod Requirements:
      - Non-Jailbroken/Jailed or Jailbroken iPhone/iPad/iPod Touch.
      - Sideloadly / Cydia Impactor or alternatives.
      - A Computer Running Windows/macOS/Linux with iTunes installed.


      Hack Features:
      - Damage Multiplier
      - Defence Multiplier
      - Moves Modifier


      Jailbreak required hack(s): https://iosgods.com/topic/173174-slime-legion-v162-3-cheats-damage-defence/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 156 replies
    • Slime Legion v3.3.0 +3 Cheats [ Damage & Defence ]
      Modded/Hacked App: Slime Legion By Perfeggs
      Bundle ID: com.hero.may.cry.adventure.game
      iTunes Store Link: https://apps.apple.com/us/app/slime-legion/id1664686966
       

      Hack Features:
      - Damage Multiplier
      - Defence Multiplier
      - Moves Modifier


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 140 replies
    • Idle Breaker v1.4.0 +5++ Cheats [ Unlimited Everything ]
      Modded/Hacked App: Idle Breaker By Estoty LLC
      Bundle ID: com.idlesurvivor.game
      iTunes Store Link: https://apps.apple.com/us/app/idle-breaker/id6448195469?uo=4


      Hack Features:
      - Unlimited Everything -> Earn some.
      - Damage Multiplier
      - Health Mulitplier
      - Tool Damage Multiplier
      - Speed Multiplier


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Idle Breaker v1.0.31 +4++ Jailed Cheats [ Unlimited Everything ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 63 replies
    • SpongeBob Adventures: In A Jam v2.23.1 +1++ Jailed Cheats [ Everything ]
      Modded/Hacked App: SpongeBob Adventures: In A Jam By Tilting Point LLC
      Bundle ID: com.tiltingpoint.sbadventures
      iTunes Store Link: https://apps.apple.com/us/app/spongebob-adventures-in-a-jam/id1641251535?uo=4


      Hack Features:
      - Unlimited Everything -> Will increase instead of decrease.


      Jailbreak required hack(s): [Mod Menu Hack] SpongeBob Adventures: In A Jam +20++ Cheats [ Cheat Menu ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 135 replies
    • SpongeBob Adventures: In A Jam v2.23.1 +1++ Cheats [ Everything ]
      Modded/Hacked App: SpongeBob Adventures: In A Jam By Tilting Point LLC
      Bundle ID: com.tiltingpoint.sbadventures
      iTunes Store Link: https://apps.apple.com/us/app/spongebob-adventures-in-a-jam/id1641251535?uo=4


      Hack Features:
      - Unlimited Everything -> Will increase instead of decrease.


      Non-Jailbroken & No Jailbreak required hack(s): [No Jailbreak Required] SpongeBob Adventures: In A Jam +20++ Jailed Cheats [ Cheat Menu ] - ViP Non-Jailbroken Hacks & Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 162 replies
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines