This script creates a variable that's a Math::BigInt object, and then changes that variable into a normal integer value:
use warnings; use strict; use Math::BigInt; use Devel::Peek; my $x = Math::BigInt->new(42); Dump $x; # Shows that $x is a # Math::BigInt object print "\n ########\n ########\n\n"; $x = "$x" + 0; Dump $x; # Shows that $x is # a normal integer
That's my answer to the question that I'm guessing you want answered.

That script outputs:
SV = PV(0x2ee308) at 0x3481a0 REFCNT = 1 FLAGS = (ROK) RV = 0x2ed750 SV = PVHV(0x32d528) at 0x2ed750 REFCNT = 1 FLAGS = (OBJECT,SHAREKEYS) STASH = 0x350118 "Math::BigInt ARRAY = 0x334b38 (0:6, 1:2) hash quality = 125.0% KEYS = 2 FILL = 2 MAX = 7 Elt "sign" HASH = 0x46c14520 SV = PV(0x2ee298) at 0x33dd58 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x24f9288 "+"\0 CUR = 1 LEN = 10 COW_REFCNT = 1 Elt "value" HASH = 0xaea09fe1 SV = IV(0x33de38) at 0x33de48 REFCNT = 1 FLAGS = (ROK) RV = 0x33dda0 SV = PVAV(0x2ef240) at 0x33dda0 REFCNT = 1 FLAGS = () ARRAY = 0x2871cc8 FILL = 0 MAX = 0 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = IV(0x33dd78) at 0x33dd88 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42 PV = 0x2ed750 "" CUR = 0 LEN = 0 ######## ######## SV = PVIV(0x346738) at 0x3481a0 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42 PV = 0
Only caveat I can spot is that if $x had been created as my $x = 42; then the PV slot would not have been set at all (on perl-5.24.0, anyway).

Cheers,
Rob

In reply to Re: convert bigint to int by syphilis
in thread convert bigint to int by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.