Page 1 of 1

Dudas con Operadores

Posted: Sat Nov 24, 2007 6:32 am
by ricardog
Alguien me puede hechar una mano con lo siguiente :

En VB :
Dim resultValue As Integer
resultValue = 11 \ 4
resultValue = 9 \ 3
resultValue = 100 \ 3
resultValue = 67 \ -3

!! OJO CON EL OPERADOR " \ "
Divide dos números y devuelve un resultado de número entero.
en el ejemplo anterior devuelven valores de 2, 3, 33 y -22

Cual seria su equivalente en XHarbour ?.

Por su atencion Gracias.

Ricardo E. Guardado Flores.

Posted: Sat Nov 24, 2007 7:51 am
by Antonio Linares
resultValue = Int( 11 \ 4 )
resultValue = Int( 9 \ 3 )
resultValue = Int( 100 \ 3 )
resultValue = Int( 67 \ -3 )

Posted: Sat Nov 24, 2007 5:14 pm
by Armando
Maestro:

No debería ser así ?

resultValue = Int( 11 / 4 )
resultValue = Int( 9 / 3 )
resultValue = Int( 100 / 3 )
resultValue = Int( 67 / -3 )

Saludos

Posted: Sat Nov 24, 2007 5:17 pm
by Antonio Linares
Si, asi es. Me limite a copiar y pegar las lineas de Ricardo :-)

Posted: Sat Nov 24, 2007 8:37 pm
by Armando
:D

Posted: Sat Nov 24, 2007 9:13 pm
by ricardog
Asi es, Estaba aplicando la funcion INT(x/i......)
Pero el resultado no era el mismo que VB asi que por eso mi pregunta.


Entonces:

VB

xNumber = (((37 + _
((512 - 448) \ 8)) \ _
(512 \ 8) + 1) * _
(512 \ 32))

EL valor de xNumber es 16 (Segun el Debugger de VB )

XHB

xNumber := Int( ((( 37 + ;
( Int( ( 512 - 448) / 8)) ) / ;
( Int( 512 / 8)) ) + 1) * ;
( Int( 512 / 32)) )

EL valor de xNumber es 27

Estoy aplicando mal la funcion INT(.....) ????????????????????????'

Ricardo E. Guardado Flores

Posted: Fri Nov 30, 2007 3:31 pm
by ADBLANCO
De hecho, el resultado de ambas formulas es 27, estoy tratando de ver como debe ser para que te de 16
:shock:

Posted: Fri Nov 30, 2007 3:45 pm
by ADBLANCO
(int((37 +((512 - 448) / 8)) /(512 / 8) + 1) *(512 / 32))




esto si da 16, revisa, que es lo que quieres hacer


Felicidad!!!