ArithmeticValue.st
changeset 7391 55ca5a24162a
parent 7385 852e84340d2b
child 7393 23344038fa0e
equal deleted inserted replaced
7390:1e770c64a291 7391:55ca5a24162a
   817 !
   817 !
   818 
   818 
   819 exp
   819 exp
   820     "return e ^ receiver"
   820     "return e ^ receiver"
   821 
   821 
   822     ^ self asFloat exp
   822     ^ self class e raisedTo:self
   823 !
   823 !
   824 
   824 
   825 floorLog:radix
   825 floorLog:radix
   826     "return the logarithm truncated as an integer"
   826     "return the logarithm truncated as an integer"
   827 
   827 
  1046 
  1046 
  1047     ^ self asFloat arcCos
  1047     ^ self asFloat arcCos
  1048 !
  1048 !
  1049 
  1049 
  1050 arcCosh
  1050 arcCosh
  1051     "return the hyperbolic arccosine of the receiver (in radians)"
  1051     "return the hyperbolic arccosine of the receiver."
  1052 
  1052 
  1053     ^ self asFloat arcCosh
  1053     ^ self asFloat arcCosh
  1054 !
  1054 !
  1055 
  1055 
  1056 arcSin
  1056 arcSin
  1058 
  1058 
  1059     ^ self asFloat arcSin
  1059     ^ self asFloat arcSin
  1060 !
  1060 !
  1061 
  1061 
  1062 arcSinh
  1062 arcSinh
  1063     "return the hyperbolic arcsine of the receiver (in radians)"
  1063     "return the hyperbolic arcsine of the receiver."
  1064 
  1064 
  1065     ^ self asFloat arcSinh
  1065     ^ self asFloat arcSinh
  1066 !
  1066 !
  1067 
  1067 
  1068 arcTan
  1068 arcTan
  1069     "return the arctangens of the receiver (in radians)"
  1069     "return the arctangent of the receiver (as radians)"
  1070 
  1070 
  1071     ^ self asFloat arcTan
  1071     ^ self asFloat arcTan
  1072 !
  1072 !
  1073 
  1073 
  1074 arcTanh
  1074 arcTanh
  1075     "return the hyperbolic arctangens of the receiver (in radians)"
  1075     "return the hyperbolic arctangent of the receiver."
  1076 
  1076 
  1077     ^ self asFloat arcTanh
  1077     ^ self asFloat arcTanh
  1078 !
  1078 !
  1079 
  1079 
  1080 cos
  1080 cos
  1082 
  1082 
  1083     ^ self asFloat cos
  1083     ^ self asFloat cos
  1084 !
  1084 !
  1085 
  1085 
  1086 cosh
  1086 cosh
  1087     "return the hyperbolic cosine of the receiver (interpreted as radians)"
  1087     "return the hyperbolic cosine of the receiver"
  1088 
  1088 
  1089     ^ self asFloat cosh
  1089     ^ (self exp + (self negated exp)) / 2
  1090 !
  1090 !
  1091 
  1091 
  1092 sin
  1092 sin
  1093     "return the sine of the receiver (interpreted as radians)"
  1093     "return the sine of the receiver (interpreted as radians)"
  1094 
  1094 
  1095     ^ self asFloat sin
  1095     ^ self asFloat sin
  1096 !
  1096 !
  1097 
  1097 
  1098 sinh
  1098 sinh
  1099     "return the hyperbolic sine of the receiver (interpreted as radians)"
  1099     "return the hyperbolic sine of the receiver"
  1100 
  1100 
  1101     ^ self asFloat sinh
  1101     ^ (self exp - (self negated exp)) / 2
  1102 !
  1102 !
  1103 
  1103 
  1104 tan
  1104 tan
  1105     "return the tangens of the receiver (interpreted as radians)"
  1105     "return the tangens of the receiver (interpreted as radians)"
  1106 
  1106 
  1107     ^ self asFloat tan
  1107     ^ self asFloat tan
  1108 !
  1108 !
  1109 
  1109 
  1110 tanh
  1110 tanh
  1111     "return the hyperbolic tangens of the receiver (interpreted as radians)"
  1111     "return the hyperbolic tangens of the receiver"
  1112 
  1112 
  1113     ^ self asFloat tanh
  1113     |exp nexp|
       
  1114 
       
  1115     "/ tanh is:
       
  1116     "/      sinh(x)
       
  1117     "/      -------
       
  1118     "/      cosh(x)
       
  1119     "/
       
  1120     "/ which is:
       
  1121     "/      (exp(x) - exp(-x)) / 2
       
  1122     "/      ----------------------
       
  1123     "/      (exp(x) + exp(-x)) / 2
       
  1124     
       
  1125     exp := self exp.
       
  1126     nexp := self negated exp.
       
  1127 
       
  1128     ^ ((exp - nexp) / (exp + nexp)) / 2
  1114 ! !
  1129 ! !
  1115 
  1130 
  1116 !ArithmeticValue methodsFor:'truncation & rounding'!
  1131 !ArithmeticValue methodsFor:'truncation & rounding'!
  1117 
  1132 
  1118 ceiling
  1133 ceiling
  1164 ! !
  1179 ! !
  1165 
  1180 
  1166 !ArithmeticValue class methodsFor:'documentation'!
  1181 !ArithmeticValue class methodsFor:'documentation'!
  1167 
  1182 
  1168 version
  1183 version
  1169     ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.50 2003-06-17 09:11:17 cg Exp $'
  1184     ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.51 2003-06-17 11:51:43 cg Exp $'
  1170 ! !
  1185 ! !
  1171 
  1186 
  1172 ArithmeticValue initialize!
  1187 ArithmeticValue initialize!