Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3217972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:28:25+00:00 2026-05-17T15:28:25+00:00

I confuse that how I aseert quite large number by PHPUnit. I wrote fibonacci

  • 0

I confuse that how I aseert quite large number by PHPUnit.
I wrote fibonacci number. But in case 100, I wrote below.

http://github.com/sanemat/kata-fibonacci-phpunit/commit/b6b2945d2eff1b95e7e25b8be8c7bff11098d44d

I expect this return TRUE.
It failed.

http://www.php.net/manual/en/language.types.float.php

I understood ‘never compare for equality.’ and so how to aseert it?
At the end, I compare with to_string each other.
How to compare large number in PHP ?

http://github.com/sanemat/kata-fibonacci-phpunit/commit/70a0e47bc0737be47da8fe8726634edd851d940d

I feel it as bad smell. But I do not know better way.
Please tell me how do you assert it?

====
php > $a = 354224848179261915075;
php > echo $a;
3.5422484817926E+20
php > $b = 3.5422484817926E+20;
php > echo $b;
3.5422484817926E+20
php > echo ($a == $b) ? 'TRUE' : 'FALSE';
FALSE
php > echo gmp_cmp($a, $b);
PHP Warning:  gmp_cmp(): Unable to convert variable to GMP - wrong type in php shell code on line 1
php > echo (strval($a) == strval($b)) ? 'TRUE' : 'FALSE';
TRUE
====

environment
$ uname -a
Linux localhost.localdomain 2.6.33.6-147.2.4.fc13.x86_64 #1 SMP Fri Jul 23 17:14:44 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
$ php --version
PHP 5.3.3 (cli) (built: Jul 22 2010 15:57:00) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:28:25+00:00Added an answer on May 17, 2026 at 3:28 pm

    To work with large numbers, there is BCMath libray of PHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am little bit confuse that I am showing images through css it's working
i m getting confuse taking to that question why all variable names and values
Writing htaccess that allows me to remove index.php from the URL can confuse search
I have functions that return an object, but I'm confused that should I return
In URL rewriting, i am quite confused that should i use underscore (_) OR
I little confuse in NSMutableDictionary retrieving Key and Value checking for that i did
I'm really confuse that How can I represent fragments as a View (Items) in
There are two questions that confuse me: I read from the Microsoft website that
I have been developing a game and I'm confuse that How can I use
I really confuse that a behavior of id() function on IronPython who differ from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.