Req #62375 [Com]: Add constant "GMP_LIMB_BITS" to GMP

From: Date: Thu, 24 Sep 2015 20:43:32 +0000
Subject: Req #62375 [Com]: Add constant "GMP_LIMB_BITS" to GMP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196218@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62375&edit=1

 ID:                 62375
 Comment by:         rainer dot jung at kippdata dot de
 Reported by:        info at bastian-born dot de
 Summary:            Add constant "GMP_LIMB_BITS" to GMP
 Status:             Open
 Type:               Feature/Change Request
 Package:            GNU MP related
 Operating System:   All
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Agreed, that patch would be very useful. For example the ext/gmp/tests/gmp_random_seed.phpt test
currently fails on Solaris, because it only works when GMP_LIMB_BITS is 64. On Solaris 32 Bits Sparc
it is 32 and gmp_random() produces other values.


Previous Comments:
------------------------------------------------------------------------
[2012-06-20 18:16:47] info at bastian-born dot de

Description:
------------
For the gmp_random() function you need the number of bits per limb to calculate the correct limiter
value (parameter).
This patch will register the constant "GMP_LIMB_BITS".

Test script:
---------------
<?php

echo "Bitcount: " . GMP_LIMB_BITS . "\n";
echo "Random with 128bit length: " . gmp_strval( gmp_random( 128 / GMP_LIMB_BITS ) );

Expected result:
----------------
Bitcount: 64
Random with 128bit length: 100835271651583136351260143038692948194



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=62375&edit=1


Thread (5 messages)

« previous php.bugs (#196218) next »