Overflow on divide with double

I am working on a script to set quota’s 500 meg above the current database size.

It has been curious to work with as the size is in bytes, but the quota is in kbytes.

works great if the mail file is less than 1Gig in size. I trying to add 500Meg to existing quotas - so for a 4 gig mail file - the quota entry via the Admin client would be 4500MB.

I get an overflow error when working with numbers that large. Even if the numbers are set to type double.

any ideas?

Subject: overflow on divide with double

Hi Neil,Did you try the Long data type?

Subject: RE: overflow on divide with double

The db.size is double and will not become long. But in my research, I was under the impression that double is much larger than long (or can be).

But I did try.

Subject: RE: overflow on divide with double

Post some code, did you try

Dim TmpSize as Long

TmpSize = CLng ( db.size)

Subject: RE: overflow on divide with double

That is the frustrating thing…

It works great for any db <1G in size. I have a user - the 4th one (as it executes alphabetically - last name) the first 3 work fine.

THe last (4Gig) dies with overflow.

            Dim dbsizeG As Long

Dim dbsizeM  As Long

Dim dbsizeK As Long

Dim oldquota As Long

Dim newquota As Long

Dim nab As NotesDatabase

Dim nabview As NotesView	

Dim c As Double



Set s = New NotesSession

Set curdb = s.CurrentDatabase

Set curdoc = New NotesDocument(curdb)

Set nab = New NotesDatabase("","names.nsf")

Set nabview = nab.GetView("People")

Set pdoc = nabview.GetFirstDocument

c=c+1

While Not (pdoc Is Nothing) 

Set userdb =  New NotesDatabase( pdoc.mailserver(0), pdoc.mailfile(0) )

	If userdb.isopen = True Then ' makes sure there is a database there

		

		dbsizeG = Clng(userdb.Size)

		dbsizeM = (dbsizeG\1024)

I have tried dbsize\1024# or 1024.0 etc.

I need to make the database size in bytes match the quota size measured in kbytes.

Subject: RE: overflow on divide with double

You’ll have to find the floor yourself. The integer division operator appears to mean literally that – it works in Integers (not Longs). Do a floating-point division, then use Fix to get the floor.

Subject: Fix for overflow on divide with double

The error is in fact just that you are using a "" instead of a “/” when dividing.

Subject: RE: overflow on divide with double

Did you try :

Dim dbSizeG as double ’ yours is long

Dim dbSizeM as double ’ yours is long

dbSizeG=cdbl(userdb.Size)

dbSizeM=cdbl(dbSizeG/cdbl(1024)) '<- force the 1024 as double

Renaud