Error: Bignum too big to convert into `long'

Nope....that doesn't work either.

  def self.ad2time(timestamp)
    # CONVERT NEVER EXPIRES 'accountExpires' NUMBER TO 12/31/2099 TO GET AROUND BIGNUM PROBLEM ON SOLARIS
    if timestamp == "9223372036854775807"
      timestamp = "157468536000000000"
    end
    ad_epoch = 116_444_736_000_000_000
    ad_multiplier = 10_000_000
    Time.at((timestamp.to_i - ad_epoch) / ad_multiplier)
  end

I ran through the calculation in irb and get this...

irb(main):003:0> 157468536000000000 - 116_444_736_000_000_000
=> 41023800000000000
irb(main):004:0> 41023800000000000/10_000_000
=> 4102380000
irb(main):005:0> Time.at(4102380000)
RangeError: bignum too big to convert into `long'
        from (irb):5:in `at'
        from (irb):5

So Solaris can't even work with a date in this century? That's bad....

I ran the exact same numbers through irb on my Mac and it works just fine...

157468536000000000 - 116_444_736_000_000_000

=> 41023800000000000

41023800000000000/10_000_000

=> 4102380000

Time.at(4102380000)

=> Thu Dec 31 00:00:00 -0600 2099

Another reason for me to dislike Solaris SPARC.

Matt

···

----- Original Message -----
From: "Matt Mencel" <MR-Mencel@wiu.edu>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Tuesday, August 10, 2010 8:40:54 AM
Subject: Re: Error: Bignum too big to convert into `long'

Ah...

9223372036854775807 is the timestamp value assigned to the "accountExpires" attribute in Active Directory when any account is set to "Never Expire".

It works fine on Linux/Mac but not on Solaris. I guess I'll just convert that timestamp to something like 12/31/2099 23:59:59 before I run the Time.at.

Matt

----- Original Message -----
From: "Brian Candler" <b.candler@pobox.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Tuesday, August 10, 2010 7:53:24 AM
Subject: Re: Error: Bignum too big to convert into `long'

Try your example values in irb:

irb(main):003:0> (9223372036854775807 - 116_444_736_000_000_000) /
10_000_000
=> 910692730085
irb(main):004:0> Time.at(910692730085)
RangeError: bignum too big to convert into `long'
  from (irb):4:in `at'
  from (irb):4

Time.at expects number of seconds since Jan 1, 1970.

The value you have given it is some time in the year 30,828 :slight_smile:

I suspect either your epoch or your multiplier is wrong.

B.
--
Posted via http://www.ruby-forum.com/\.

Nope....that doesn't work either.

def self.ad2time(timestamp)
   # CONVERT NEVER EXPIRES 'accountExpires' NUMBER TO 12/31/2099 TO GET AROUND BIGNUM PROBLEM ON SOLARIS
   if timestamp == "9223372036854775807"
     timestamp = "157468536000000000"
   end
   ad_epoch = 116_444_736_000_000_000
   ad_multiplier = 10_000_000
   Time.at((timestamp.to_i - ad_epoch) / ad_multiplier)
end

I ran through the calculation in irb and get this...

irb(main):003:0> 157468536000000000 - 116_444_736_000_000_000
=> 41023800000000000
irb(main):004:0> 41023800000000000/10_000_000
=> 4102380000
irb(main):005:0> Time.at(4102380000)
RangeError: bignum too big to convert into `long'
       from (irb):5:in `at'
       from (irb):5

So Solaris can't even work with a date in this century? That's bad....

I ran the exact same numbers through irb on my Mac and it works just fine...

157468536000000000 - 116_444_736_000_000_000

=> 41023800000000000

41023800000000000/10_000_000

=> 4102380000

Time.at(4102380000)

=> Thu Dec 31 00:00:00 -0600 2099

Another reason for me to dislike Solaris SPARC.

Matt

32 bits of counting seconds since 1970 only gets you as far as 2038. You apparently dislike 32-bit systems and not just Solaris SPARC.

-Rob

From: "Matt Mencel" <MR-Mencel@wiu.edu>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Tuesday, August 10, 2010 8:40:54 AM
Subject: Re: Error: Bignum too big to convert into `long'

Ah...

9223372036854775807 is the timestamp value assigned to the "accountExpires" attribute in Active Directory when any account is set to "Never Expire".

It works fine on Linux/Mac but not on Solaris. I guess I'll just convert that timestamp to something like 12/31/2099 23:59:59 before I run the Time.at.

Matt

From: "Brian Candler" <b.candler@pobox.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Tuesday, August 10, 2010 7:53:24 AM
Subject: Re: Error: Bignum too big to convert into `long'

Try your example values in irb:

irb(main):003:0> (9223372036854775807 - 116_444_736_000_000_000) /
10_000_000
=> 910692730085
irb(main):004:0> Time.at(910692730085)
RangeError: bignum too big to convert into `long'
from (irb):4:in `at'
from (irb):4

Time.at expects number of seconds since Jan 1, 1970.

The value you have given it is some time in the year 30,828 :slight_smile:

I suspect either your epoch or your multiplier is wrong.

B.
--
Posted via http://www.ruby-forum.com/\.

Rob Biedenharn
Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/
rab@GaslightSoftware.com http://GaslightSoftware.com/

···

On Aug 10, 2010, at 10:51 AM, Matt Mencel wrote:

----- Original Message -----

you may let ruby do the work for you :slight_smile:
try ruby 1.9

eg,

$ ruby -ve 'puts("#{(-1.size==4?32:64)}bit", Time.at(4102380000))'
ruby 1.9.2dev (2010-07-11 revision 28618) [i686-linux]
32bit
2099-12-31 14:00:00 +0800

best regards -botp

···

On Tue, Aug 10, 2010 at 10:51 PM, Matt Mencel <MR-Mencel@wiu.edu> wrote:

Another reason for me to dislike Solaris SPARC.

Matt Mencel wrote:

Another reason for me to dislike Solaris SPARC.

You can get 64-bit Solaris SPARC can't you?

The example I posted (showing the limit for 32-bit Time) was on a 32-bit
Ubuntu machine.

Linux xxx 2.6.24-28-386 #1 Sat Jul 31 15:36:51 UTC 2010 i686 GNU/Linux

ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

I'm sure an older Mac would be the same.

···

--
Posted via http://www.ruby-forum.com/\.

Solaris 10 SPARC is 64bit. It may be the ruby version I have installed was compiled for 32bit? It's an older version of 1.8.7 off of sunfreeware.com. I noticed that sunfreeware has a newer 1.9.1 version available there now so I think I'll upgrade ruby to 1.9.1 and see what happens.

Thanks,
Matt

···

----- Original Message -----
From: "botp" <botpena@gmail.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Tuesday, August 10, 2010 9:18:30 PM
Subject: Re: Error: Bignum too big to convert into `long'

On Tue, Aug 10, 2010 at 10:51 PM, Matt Mencel <MR-Mencel@wiu.edu> wrote:

Another reason for me to dislike Solaris SPARC.

you may let ruby do the work for you :slight_smile:
try ruby 1.9

eg,

$ ruby -ve 'puts("#{(-1.size==4?32:64)}bit", Time.at(4102380000))'
ruby 1.9.2dev (2010-07-11 revision 28618) [i686-linux]
32bit
2099-12-31 14:00:00 +0800

best regards -botp

Matt Mencel wrote:

Solaris 10 SPARC is 64bit. It may be the ruby version I have installed
was compiled for 32bit? It's an older version of 1.8.7 off of
sunfreeware.com. I noticed that sunfreeware has a newer 1.9.1 version
available there now so I think I'll upgrade ruby to 1.9.1 and see what
happens.

Remember that ruby 1.9 is a significantly different language to ruby
1.8. Unless you are lucky, or fancy modifying your app to work with 1.9
(and maybe its dependent libs too), I think you'd be better off finding
a 64-bit build of ruby 1.8.7.

···

--
Posted via http://www.ruby-forum.com/\.