Dudas con Operadores

Post Reply
ricardog
Posts: 149
Joined: Tue Oct 11, 2005 3:10 pm

Dudas con Operadores

Post 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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

resultValue = Int( 11 \ 4 )
resultValue = Int( 9 \ 3 )
resultValue = Int( 100 \ 3 )
resultValue = Int( 67 \ -3 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Post 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
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Si, asi es. Me limite a copiar y pegar las lineas de Ricardo :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Post by Armando »

:D
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
ricardog
Posts: 149
Joined: Tue Oct 11, 2005 3:10 pm

Post 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
User avatar
ADBLANCO
Posts: 299
Joined: Mon Oct 22, 2007 3:03 pm
Location: Valencia - Venezuela

Post by ADBLANCO »

De hecho, el resultado de ambas formulas es 27, estoy tratando de ver como debe ser para que te de 16
:shock:
User avatar
ADBLANCO
Posts: 299
Joined: Mon Oct 22, 2007 3:03 pm
Location: Valencia - Venezuela

Post by ADBLANCO »

(int((37 +((512 - 448) / 8)) /(512 / 8) + 1) *(512 / 32))




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


Felicidad!!!
Post Reply