Hola,
los comentarios de los methods tienen una explicacion que en teoría puede
aclarar.
Aqui copio los methods de Number en un VAST 6.0 que tengo a mano.
// aNumber
"Answer an Integer representing the quotient defined by dividing the
receiver by aNumber with truncation toward negative infinity (modulo
operation)."
self subclassResponsibility
quo: aNumber
"Answer an Integer representing the quotient defined by dividing the
receiver by aNumber with truncation toward zero.
Fail if aNumber is zero."
^(self / aNumber) truncated
Alguien que quiera aclarar cual sería la diferencia entre truncation towar
negative infinity vs. toward zero?
\\ aNumber
"Answer the remainder after integer division of the receiver by aNumber.
Fail if aNumber is not a type of Number. Fail if aNumber is zero."
^self - ((self // aNumber) * aNumber)
rem: aNumber
"Answer a type of Number representing the remainder defined by dividing
the receiver by aNumber with truncation toward zero.
Fail if aNumber is not a type of Number. Fail if aNumber = 0."
"Note that the Blue Book is unclear about what remainder returns for
floats and fractions
so this implementation returns the actual remainder whose class is the
highest generality of
self and the receiver. For example, 4.5 rem: 2 = 0.5 4 rem: 5.0 =
4.0."
^self - (aNumber * (self quo: aNumber))
Siguiendo lo anterior \\ esta basado en // y rem: esta basado en quo:.
Saludos,
German
2011/7/11 Leandro Martín Malsam <[email protected]>
> Gente, estaba viendo que tengo 2 formas de obtener el cociente y el resto
> de una división, utilizando VAST, y quería preguntar cuál es la forma más
> correcta.
> En principio veo que, para cada caso, ambos métodos me devuelven el mismo
> resultado, así que parece que no voy a tener problemas, pero quiero
> asegurarme de que todo vaya a funcionar bien.
>
> Para el cociente tengo:
> #//
> #quo:
>
> Y para el resto:
> #\\
> #rem:
>
> ¿Existe alguna diferencia entre usar uno u otro para cada operación? ¿Qué
> sería lo más correcto?
>
> Gracias de antemano por sus aportes.
> Salu2
>
> Leandro
>
>
> --
> ---------------------------------------
> http://www.utnianos.com.ar
>
> --
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
>
> http://www.clubSmalltalk.org
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
http://www.clubSmalltalk.org