[ASP] Deling uitvoeren geeft overflow

Pagina: 1
Acties:

  • r0bert
  • Registratie: September 2001
  • Laatst online: 09:37
Het probleem is op zich niet moeilijk.

Ik haal 2 Integer velden uit een Access DB en die wil ik door elkaar delen om een percentage uit te rekenen..

Het ene veld heet "wpteller" de ander "teller"

Response.Write RS.Fields("wpteller").value geeft correcte waarde
Response.Write RS.Fields("teller").value geeft correcte waarde

Maar Response.Write RS.Fields("wpteller").value/RS.Fields("teller") geeft een overflow error.. Misschien komt het door dat een getal oneindig doorloopt na de deling? (1/3).. Áls het hier door komt.. hoe kan ik dit oplossen.. En anders, wat doe ik fout?

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

Converteer de opgezochte integers eens met CDbl naar een double alvorens te delen?

Professionele website nodig?


  • Tweeker
  • Registratie: April 2003
  • Laatst online: 01-10-2023

Tweeker

1 + 1 = 3

is de noemer (die jij teller noemt) niet nul (0) of null? Meestal krijg je daarom een overflow.

1 + 1 = 3


  • r0bert
  • Registratie: September 2001
  • Laatst online: 09:37
code:
1
2
3
4
Microsoft VBScript runtime error '800a0006' 
Overflow 

/overzichtwoningpresentaties.asp, line 61


ASP:
PHP:
1
(CDbl(RS.Fields("wpteller").value)/CDbl(RS.Fields("teller").value)*100)


Oh dom! ik wou zeggen, nee WPTeller is geen 0.. maar er zijn 2 panden ofzo waar dat wel zo is! DOM DOM DOM!~Thnx, nou zou het moeten werken!

[ Voor 32% gewijzigd door r0bert op 16-07-2004 16:45 ]


  • _Thanatos_
  • Registratie: Januari 2001
  • Laatst online: 15-05 14:44

_Thanatos_

Ja, en kaal

Ik dacht dat VBScript bij een deling door 0 de waarde Infinity aan het resultaat toevoegde... Of was dat weer gewoon VB?

日本!🎌


  • Zoijar
  • Registratie: September 2001
  • Niet online

Zoijar

Because he doesn't row...

Deling door nul geeft een overflow exception (int 0), evenals een 'echte' overflow. Een float kan wel de waarde infinity bevatten (bij x/0, x!=0),of NaN (bij 0/0) maar integers niet en daar ging het om in de deling.

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

Nogal idioot, een overflow is namelijk nogal wat anders dan een division-by-zero, en het geeft ook andere signals op CPU-niveau. Beetje stupide dat VB(script) ze over 1 kam scheert :/

Professionele website nodig?


  • Alex
  • Registratie: Juli 2001
  • Laatst online: 28-02 19:26
curry684 schreef op 16 juli 2004 @ 22:45:
Nogal idioot, een overflow is namelijk nogal wat anders dan een division-by-zero, en het geeft ook andere signals op CPU-niveau. Beetje stupide dat VB(script) ze over 1 kam scheert :/
Ach, VB krijgt het ook voor elkaar om een error te generen bij het converteren in een integer in een For lus:
ASP:
1
For i To CInt(blaat)

Deze post is bestemd voor hen die een tegenwoordige tijd kunnen onderscheiden van een toekomstige halfvoorwaardelijke bepaalde subinverte plagiale aanvoegend intentioneel verleden tijd.
- Giphart


  • Zoijar
  • Registratie: September 2001
  • Niet online

Zoijar

Because he doesn't row...

curry684 schreef op 16 juli 2004 @ 22:45:
Nogal idioot, een overflow is namelijk nogal wat anders dan een division-by-zero, en het geeft ook andere signals op CPU-niveau. Beetje stupide dat VB(script) ze over 1 kam scheert :/
Nee hoor, het geeft geen andere signals op cpu niveau. Dat zeg ik toch ook net...

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

Zoijar schreef op 17 juli 2004 @ 03:50:
[...]

Nee hoor, het geeft geen andere signals op cpu niveau. Dat zeg ik toch ook net...
Lijst van veel voorkomende low-level exceptions onder Win32:


ValueMeaning
EXCEPTION_ACCESS_VIOLATIONThe thread tried to read from or write to a virtual address for which it does not have the appropriate access.
EXCEPTION_ARRAY_BOUNDS_EXCEEDEDThe thread tried to access an array element that is out of bounds and the underlying hardware supports bounds checking.
EXCEPTION_BREAKPOINTA breakpoint was encountered.
EXCEPTION_DATATYPE_MISALIGNMENTThe thread tried to read or write data that is misaligned on hardware that does not provide alignment. For example, 16-bit values must be aligned on 2-byte boundaries; 32-bit values on 4-byte boundaries, and so on.
EXCEPTION_FLT_DENORMAL_OPERANDOne of the operands in a floating-point operation is denormal. A denormal value is one that is too small to represent as a standard floating-point value.
EXCEPTION_FLT_DIVIDE_BY_ZEROThe thread tried to divide a floating-point value by a floating-point divisor of zero.
EXCEPTION_FLT_INEXACT_RESULTThe result of a floating-point operation cannot be represented exactly as a decimal fraction.
EXCEPTION_FLT_INVALID_OPERATIONThis exception represents any floating-point exception not included in this list.
EXCEPTION_FLT_OVERFLOWThe exponent of a floating-point operation is greater than the magnitude allowed by the corresponding type.
EXCEPTION_FLT_STACK_CHECKThe stack overflowed or underflowed as the result of a floating-point operation.
EXCEPTION_FLT_UNDERFLOWThe exponent of a floating-point operation is less than the magnitude allowed by the corresponding type.
EXCEPTION_ILLEGAL_INSTRUCTIONThe thread tried to execute an invalid instruction.
EXCEPTION_IN_PAGE_ERRORThe thread tried to access a page that was not present, and the system was unable to load the page. For example, this exception might occur if a network connection is lost while running a program over the network.
EXCEPTION_INT_DIVIDE_BY_ZEROThe thread tried to divide an integer value by an integer divisor of zero.
EXCEPTION_INT_OVERFLOWThe result of an integer operation caused a carry out of the most significant bit of the result.
EXCEPTION_INVALID_DISPOSITIONAn exception handler returned an invalid disposition to the exception dispatcher. Programmers using a high-level language such as C should never encounter this exception.
EXCEPTION_NONCONTINUABLE_EXCEPTIONThe thread tried to continue execution after a noncontinuable exception occurred.
EXCEPTION_PRIV_INSTRUCTIONThe thread tried to execute an instruction whose operation is not allowed in the current machine mode.
EXCEPTION_SINGLE_STEPA trace trap or other single-instruction mechanism signaled that one instruction has been executed.
EXCEPTION_STACK_OVERFLOWThe thread used up its stack.


Lijkt me duidelijk :)

Professionele website nodig?


  • _Thanatos_
  • Registratie: Januari 2001
  • Laatst online: 15-05 14:44

_Thanatos_

Ja, en kaal

Wiskundig gezien is het helemaal niet raar dat je bij deling door 0 een overflow exception krijgt. Uit een deling door 0 komt (wiskundig gezien) het resultaat "oneindig", omdat hoe kleiner de deler, hoe groter de uitkomst. Dus bij een oneindig kleine deler moet je een oneindig groot resultaat hebben.

Dus die overflow komt gewoon doordat een integer niet oneindig groot kan zijn. Een float komt al dichter in de buurt, zegmaar :)

日本!🎌


  • Zoijar
  • Registratie: September 2001
  • Niet online

Zoijar

Because he doesn't row...

curry684 schreef op 17 juli 2004 @ 13:49:
Lijst van veel voorkomende low-level exceptions onder Win32:
Protected Mode Exceptions
Interrupt 0 if the quotient is too large to fit in the designated register (AL, AX, or EAX), or if the divisor is 0; #GP(0) for an illegal memory operand effective address in the CS, DS, ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment; #PF(fault-code) for a page fault

Hoe kan je dan op cpu niveau onderscheiden tussen overflow en deling door nul? Beiden geven een interrupt 0. Window kijkt misschien daarna nog of er door nul gedeeld werd oid, maar op cpu niveau is er geen verschil.

  • Gert
  • Registratie: Juni 1999
  • Laatst online: 05-12-2025
bla.vbs
code:
1
MsgBox(50/0)


Uitvoer: Error: Division by zero
Pagina: 1