dump in timeInterval

Discussions related to Visual Prolog
Matthias Greving
Posts: 18
Joined: 21 Mar 2002 0:01

dump in timeInterval

Unread post by Matthias Greving » 27 Jan 2010 16:30

Hello,

today I got a dump in Vip7.2 with this line of code

Code: Select all

I=timeInterval::new(0,0,0,3600.0),
I am aware that 3600 second might be unusual, but this line worked in Vip 7.1.
It seems to be related to the integer64 calculation in the local predicate setFields(Days, Hours, Minutes, Seconds) in timeInterval.

Any ideas?

mfg
Matthias

Steve Lympany
VIP Member
Posts: 695
Joined: 31 Mar 2001 23:01

Unread post by Steve Lympany » 1 Feb 2010 19:55

Hi,
It looks like it is math::round() returning and integer, rather than an integer64.
First, why do it?!
Anyway, if it's a problem you could replace the clause in timinterval.pro with

Code: Select all

constants         max_con=2147483647. clauses     setFields(Days, Hours, Minutes, Seconds) :-         Hours_inDays = (time_api::maxLegalHour + 1) * Days,         TotalHours = add64WithInteger(Hours_inDays, Hours),         Minutes_inHours = TotalHours * (time_api::maxLegalMinute + 1),         TotalMinutes = add64WithInteger(Minutes_inHours, Minutes),         Fractions_inMinutes = TotalMinutes * (time_api::maxLegalSecond + 1) * quantumBasis,         SecondsWithFraction = Seconds * quantumBasis,         if SecondsWithFraction<max_con then                 Int= math::round(SecondsWithFraction),                 interval := Fractions_inMinutes + Int             else                 Sec2=SecondsWithFraction-max_con,                 Int= math::round(Sec2),                 interval := Fractions_inMinutes + Int + max_con             end if.
But I'm sure there's a better way.
cheers
Steve

Matthias Greving
Posts: 18
Joined: 21 Mar 2002 0:01

Unread post by Matthias Greving » 2 Feb 2010 16:19

Hello,

thanks for your reply.
I have a work around for this issue, so it is not urgend, but I thought it would be nice to have it solved in a way that it works like before.
I know I could split the value beforhand, it is just more convenient to use huge numbers of seconds because the application I use it in works with them internally.

mfg
Matthias

User avatar
Thomas Linder Puls
VIP Member
Posts: 2448
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 7 Feb 2010 12:19

It looks like we need a 64 bit rounding predicate.

In the meantime you can change setFields like this (it is the last line that is actually changed):

Code: Select all

clauses     setFields(Days, Hours, Minutes, Seconds) :-         Hours_inDays = (time_api::maxLegalHour + 1) * Days,         TotalHours = add64WithInteger(Hours_inDays, Hours),         Minutes_inHours = TotalHours * (time_api::maxLegalMinute + 1),         TotalMinutes = add64WithInteger(Minutes_inHours, Minutes),         Fractions_inMinutes = TotalMinutes * (time_api::maxLegalSecond + 1) * quantumBasis,         SecondsWithFraction = Seconds * quantumBasis,         interval := Fractions_inMinutes + toInteger64(math::int64xReal(integer64(1,0), SecondsWithFraction)).
Regards Thomas Linder Puls
PDC

Post Reply