Vanessa Freudenberg uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-codefrau.553.mcz
==================== Summary ====================
Name: Graphics-codefrau.553
Author: codefrau
Time: 24 June 2024, 3:35:30.134138 pm
UUID: c3e3ec43-5677-48b6-a7b0-631b3a42cde2
Ancestors: Graphics-mt.552
Fix alpha corruption.
To fix the Squeak icon in the docking bar, toggle the bar on and off via world halo menu or execute
TheWorldMainDockingBar updateInstances
=============== Diff against Graphics-mt.552 ===============
Item was changed:
----- Method: Color class>>colorFromPixelValue:depth: (in category 'instance creation') -----
colorFromPixelValue: p depth: d
"Convert a pixel value for the given display depth into a color."
"Details: For depths of 8 or less, the pixel value is simply looked up in a table. For greater depths, the color components are extracted and converted into a color."
| r g b alpha |
d = 8 ifTrue: [^ IndexedColors at: (p bitAnd: 16rFF) + 1].
d = 4 ifTrue: [^ IndexedColors at: (p bitAnd: 16r0F) + 1].
d = 2 ifTrue: [^ IndexedColors at: (p bitAnd: 16r03) + 1].
d = 1 ifTrue: [^ IndexedColors at: (p bitAnd: 16r01) + 1].
(d = 16) | (d = 15) ifTrue: [
"five bits per component"
r := (p bitShift: -10) bitAnd: 16r1F.
g := (p bitShift: -5) bitAnd: 16r1F.
b := p bitAnd: 16r1F.
(r = 0 and: [g = 0]) ifTrue: [
b = 0 ifTrue: [^Color transparent].
b = 1 ifTrue: [^Color black]].
^ Color r: r g: g b: b range: 31].
d = 32 ifTrue: [
"eight bits per component; 8 bits of alpha"
r := (p bitShift: -16) bitAnd: 16rFF.
g := (p bitShift: -8) bitAnd: 16rFF.
b := p bitAnd: 16rFF.
alpha := p bitShift: -24.
alpha = 0 ifTrue: [^Color transparent].
(r = 0 and: [g = 0]) ifTrue: [
b = 0 ifTrue: [^Color transparent].
+ b = 1 ifTrue: [^alpha < 255 ifTrue: [Color black alpha: alpha / 255.0] ifFalse: [Color black]]].
- b = 1 ifTrue: [^Color black]].
alpha < 255
ifTrue: [^ (Color r: r g: g b: b range: 255) alpha: (alpha asFloat / 255.0)]
ifFalse: [^ (Color r: r g: g b: b range: 255)]].
d = 12 ifTrue: [
"four bits per component"
r := (p bitShift: -8) bitAnd: 16rF.
g := (p bitShift: -4) bitAnd: 16rF.
b := p bitAnd: 16rF.
^ Color r: r g: g b: b range: 15].
d = 9 ifTrue: [
"three bits per component"
r := (p bitShift: -6) bitAnd: 16r7.
g := (p bitShift: -3) bitAnd: 16r7.
b := p bitAnd: 16r7.
^ Color r: r g: g b: b range: 7].
self error: 'unknown pixel depth: ', d printString
!
Marcel Taeumel uploaded a new version of SUnitGUI to project The Trunk:
http://source.squeak.org/trunk/SUnitGUI-mt.94.mcz
==================== Summary ====================
Name: SUnitGUI-mt.94
Author: mt
Time: 17 June 2024, 2:38:46.583923 pm
UUID: ef9fd219-2fa3-bb4c-a3ef-409239535573
Ancestors: SUnitGUI-tpr.93
Fixes quite old regression/bug in the calculation of test coverage using exclusion rules. For classes, #methods answers a reader object and not something that understands #do:. So we must use #methodsDo: directly.
=============== Diff against SUnitGUI-tpr.93 ===============
Item was changed:
----- Method: TestRunner>>excludeClassesNotUnderTestFrom: (in category 'actions') -----
excludeClassesNotUnderTestFrom: methods
classesSelected do:
[ :class |
(class class includesSelector: #classNamesNotUnderTest) ifTrue:
[ class classNamesNotUnderTest do:
[ :className | | theClass |
theClass := Smalltalk classNamed: className.
theClass ifNotNil:[
+ theClass methodsDo:
- theClass methods do:
[ :each |
methods
remove: each methodReference
ifAbsent: [ ] ].
+ theClass class methodsDo:
- theClass class methods do:
[ :each |
methods
remove: each methodReference
ifAbsent: [ ] ]] ] ] ]!
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.1257.mcz
==================== Summary ====================
Name: Tools-eem.1257
Author: eem
Time: 14 June 2024, 12:40:43.16157 pm
UUID: 3a6332e4-8d30-4ecf-af02-972aac922031
Ancestors: Tools-eem.1256
Fix PackagePaneBrowser>>selectSystemCategory:, having broken it in Tools-eem.1236. The issue is that if one uses find class... in the PackagePaneBrowser's system category/package sub-category list (the second pane) then the package should change if the found class is not in the package. But the search is tricky. We could be selecting a new package, or a sub-component in the package, in which case the selected package should not change.
This fixes the PackagePaneBrowser. It does not fix the two tests, testClassList & testSelectCategoryForClass.
Also add a guard to PackagePaneBrowser>>#classList when no package is selected (package is nil).
=============== Diff against Tools-eem.1256 ===============
Item was changed:
----- Method: PackagePaneBrowser>>classList (in category 'class list') -----
classList
self hasSystemCategorySelected ifTrue:
+ [self package ifNotNil:
+ [:thisPackage| | thisCatSufix categories |
+ thisCatSufix := self selectedSystemCategoryWithoutPackage.
+ categories := systemOrganizer categories select: [:eachCat |
+ eachCat size >= thisPackage size
+ and: ["package prefix may occur in different cases, because they are assembled in the same package"
+ ((eachCat first: thisPackage size) compare: thisPackage caseSensitive: false) = 2]
+ and: ["rest of system category must have exact case, because it is discrimnated by the system category list"
+ (eachCat allButFirst: thisPackage size) = thisCatSufix]].
+ categories ifNotEmpty:
+ [^categories gather: [:eachCat | systemOrganizer listAtCategoryNamed: eachCat]]]].
+
- [| thisPackage thisCatSufix categories |
- thisPackage := self package.
- thisCatSufix := self selectedSystemCategoryWithoutPackage.
- categories := systemOrganizer categories select: [:eachCat |
- eachCat size >= thisPackage size
- and: ["package prefix may occur in different cases, because they are assembled in the same package"
- ((eachCat first: thisPackage size) compare: thisPackage caseSensitive: false) = 2]
- and: ["rest of system category must have exact case, because it is discrimnated by the system category list"
- (eachCat allButFirst: thisPackage size) = thisCatSufix]].
- categories ifNotEmpty:
- [^categories gather: [:eachCat | systemOrganizer listAtCategoryNamed: eachCat]]].
-
self hasPackageSelected ifTrue:
[^ self packageClasses].
^ systemOrganizer allElements!
Item was changed:
----- Method: PackagePaneBrowser>>selectSystemCategory: (in category 'system category list') -----
selectSystemCategory: aSymbol
+ "Override to set packageListIndex correctly, if required."
+ | newPackageListIndex |
- "Override to set packageListIndex correctly."
super selectSystemCategory: aSymbol.
+ aSymbol ifNil: [^self].
+ "aSymbol may be the name of a sub-package, e.g. 'Browser' within 'Tools-Browser',
+ or it may be a full string, such as 'PackageInfo-Base'. The packageListIndex only
+ needs to change if aSymbol is of the latter form. So first try and find it within the
+ current package."
+ (aSymbol includes: $-) ifFalse:
+ [self selectedPackageName ifNotNil:
+ [:spn|
+ self systemOrganizer categories do:
+ [:cat|
+ (cat = spn
+ or: [(cat beginsWith: spn) and: [(cat at: spn size + 1) = $-]]) ifTrue:
+ [((cat subsequences: $-) includes: aSymbol) ifTrue:
+ [^self]]]]].
+ "thus far aSymbol is not a sub-package in the current package. update the packageList to the most specific
+ package containing it, iff such a package exists."
+ newPackageListIndex := selectedSystemCategory
+ ifNil: [0]
+ ifNotNil:
+ [:ssc| | sscComponents maxMatch maxMatchIndex |
+ "find the longest package name that the selectedSystemCategory begins with.
+ e.g. if selectedSystemCategory is #'Tools-Browser', but the list only
+ contains 'Tools', select 'Tools' as the packageListIndex'. But don't be fooled
+ into selecting ToolsTests."
+ sscComponents := ssc subsequences: $-.
+ maxMatch := 0.
+ maxMatchIndex := 0.
+ [:break|
+ self packageList withIndexDo:
+ [:packageName :index| | pnComponents |
+ pnComponents := packageName subsequences: $-.
+ (sscComponents beginsWith: pnComponents) ifTrue:
+ [sscComponents = pnComponents ifTrue:
+ [maxMatchIndex := index.
+ break value].
+ pnComponents size > maxMatch ifTrue:
+ [maxMatch := pnComponents.
+ maxMatchIndex := index]]]] valueWithExit.
+ maxMatchIndex].
+ (newPackageListIndex ~= 0
+ and: [packageListIndex ~= newPackageListIndex]) ifTrue:
+ [packageListIndex := newPackageListIndex.
+ self changed: #packageListIndex]!
- packageListIndex := selectedSystemCategory
- ifNil: [0]
- ifNotNil:
- [:ssc| | maxMatch maxMatchIndex |
- "find the longest package name that the selectedSystemCategory begins with.
- e.g. if selectedSystemCategory is #'Tools-Browser', but the only
- contains 'Tools', select 'Tools' as the packageListIndex'"
- maxMatch := 0.
- maxMatchIndex := 0.
- [:break|
- self packageList withIndexDo:
- [:packageName :index|
- (ssc beginsWith: packageName) ifTrue:
- [ssc = packageName ifTrue:
- [maxMatchIndex := index.
- break value].
- packageName size > maxMatch ifTrue:
- [maxMatch := packageName size.
- maxMatchIndex := index]]]] valueWithExit.
- maxMatchIndex]!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1569.mcz
==================== Summary ====================
Name: Kernel-eem.1569
Author: eem
Time: 7 June 2024, 1:37:40.715641 pm
UUID: e502a31d-cf08-46f5-ad4b-37d650da83b5
Ancestors: Kernel-dtl.1568
Add the new primitives for cosine, available only in VMs built from commit 0b5e3c3878bdf0f51e0e6a6d877932a656c3dffe,
CogVM source as per VMMaker.oscog-eem.3382
=============== Diff against Kernel-dtl.1568 ===============
Item was added:
+ ----- Method: BoxedFloat64>>cos (in category 'mathematical functions') -----
+ cos
+ "Answer the cosine of the receiver taken as an angle in radians."
+ <primitive: 150>
+
+ ^super cos!
Item was added:
+ ----- Method: SmallFloat64>>cos (in category 'mathematical functions') -----
+ cos
+ "Answer the cosine of the receiver taken as an angle in radians."
+ <primitive: 560>
+
+ ^super cos!
David T. Lewis uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-dtl.1568.mcz
==================== Summary ====================
Name: Kernel-dtl.1568
Author: dtl
Time: 5 June 2024, 9:40:46.422483 pm
UUID: 8a83f4ec-8602-40a0-b2fc-c7e64eada55d
Ancestors: Kernel-dtl.1567
Adapt 6350-sin-cos-ForHugeIntegersAndFractions-JuanVuletich-2024May07-15h42m-jmv.001.cs.st from Cuis to Squeak
=============== Diff against Kernel-dtl.1567 ===============
Item was changed:
----- Method: Integer>>moduloTwoPiAsFloat (in category 'converting') -----
moduloTwoPiAsFloat
"Answer the remainder of the division by 2 * pi, as a Floating Point number.
Provides full Float precision of the remainder result, even for huge arguments.
See comment at Fraction.
See senders."
+ ^(Fraction numerator: self denominator: 1) moduloTwoPiAsFloat!
- ^self asFraction moduloTwoPiAsFloat!
Item was added:
+ ----- Method: ScaledDecimal>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders."
+
+
+ ^ self asFraction moduloTwoPiAsFloat!
David T. Lewis uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-dtl.1567.mcz
==================== Summary ====================
Name: Kernel-dtl.1567
Author: dtl
Time: 5 June 2024, 9:39:12.921619 pm
UUID: 0c221a10-906c-429b-9b67-cb2e61b4ca20
Ancestors: Kernel-mt.1566
Initial load of 6350-sin-cos-ForHugeIntegersAndFractions-JuanVuletich-2024May07-15h42m-jmv.001.cs.st from Cuis from original commit:
commit 8a866980bb705135aae3299506a8d864dd2ac1e5
Author: Juan Vuletich <juan(a)jvuletich.org>
Date: Tue May 7 15:46:44 2024 -0300
Correct behavior for #sin, #cos, #tan for huge Integers and Fractions.
=============== Diff against Kernel-mt.1566 ===============
Item was added:
+ ----- Method: Fraction class>>pi1000Digits (in category 'approximations') -----
+ pi1000Digits
+ "
+
+ Integer pi1000Digits asNumber
+ Integer pi1000Digits asNumber class
+ Integer pi1000Digits asNumber / (10 raisedToInteger: Integer pi1000Digits size - 1) :: asFloat
+ Integer pi1000Digits asNumber+1 / (10 raisedToInteger: Integer pi1000Digits size - 1) :: asFloat
+ "
+
+ ^'314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921
6420198' .!
Item was added:
+ ----- Method: Fraction class>>piAsFraction: (in category 'approximations') -----
+ piAsFraction: numberOfDecimals
+ "Answer a Fraction built with the first numberOfDigits decimal digits of Pi.
+ Note: It will always be less than the Real Pi. It is not a rounded version of Pi, but a truncated version of pi.
+ Fraction piAsFraction: 5
+ "
+ ^(Fraction piDigitsAsInteger: numberOfDecimals) / (10 raisedToInteger: numberOfDecimals)!
Item was added:
+ ----- Method: Fraction class>>piDigitsAsInteger: (in category 'approximations') -----
+ piDigitsAsInteger: numberOfDecimals
+ "Answer an integer number formed by the first numberOfDecimals+1 digits of pi.
+ If numberOfDecimals=2, answer 314.
+ If numberOfDecimals=4, answer 31415
+
+ Fraction piDigitsAsInteger: 2
+ Fraction piDigitsAsInteger: 4
+ "
+ | answer characterStream manyDigits |
+ manyDigits := self pi1000Digits.
+ numberOfDecimals < manyDigits size ifFalse: [
+ ^self error: 'Can not approximate pi with so many decimals' ].
+ characterStream := manyDigits readStream.
+ answer := characterStream next digitValue.
+ numberOfDecimals timesRepeat: [
+ answer := 10 * answer + characterStream next digitValue ].
+ ^answer!
Item was added:
+ ----- Method: Fraction>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Useful for periodic functions definded on Floats.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ Evaluate comments below and compare results.
+ See senders."
+ "
+ | bigNum |
+ bigNum := 1e22 + (10202/10000).
+ {'wrong!!'. bigNum asFloat sin. bigNum asFloat cos} print.
+ {'wrong!!'. (bigNum+1) asFloat sin. (bigNum+1) asFloat cos} print.
+ {'correct!!'. bigNum moduloTwoPiAsFloat sin. bigNum moduloTwoPiAsFloat cos} print.
+ {'correct!!'. (bigNum+1) moduloTwoPiAsFloat sin. (bigNum+1) moduloTwoPiAsFloat cos} print.
+ {'Reference:'. 0 sin. 0 cos} print.
+ {'Reference:'. 1 sin. 1 cos} print.
+ "
+ "
+ | bigNum |
+ bigNum := 1e500 - (282532 / 100000).
+ {'wrong!!'. bigNum asFloat sin. bigNum asFloat cos} print.
+ {'wrong!!'. (bigNum+1) asFloat sin. (bigNum+1) asFloat cos} print.
+ {'correct!!'. bigNum moduloTwoPiAsFloat sin. bigNum moduloTwoPiAsFloat cos} print.
+ {'correct!!'. (bigNum+1) moduloTwoPiAsFloat sin. (bigNum+1) moduloTwoPiAsFloat cos} print.
+ {'Reference:'. 0 sin. 0 cos} print.
+ {'Reference:'. 1 sin. 1 cos} print.
+ "
+ "
+ (1e22 \\ Float twoPi) print.
+ (1e22+1 \\ Float twoPi) print.
+ 1e22 moduloTwoPiAsFloat print.
+ (1e22+1) moduloTwoPiAsFloat print.
+ (1e500 \\ Float twoPi) print.
+ (1e500+1 \\ Float twoPi) print.
+ 1e500 moduloTwoPiAsFloat print.
+ (1e500+1) moduloTwoPiAsFloat print.
+ "
+
+ | numberOfPiDecimals twoPiFraction |
+ (self positive and: [ self <= (628/100) ]) ifTrue: [
+ ^self asFloat ].
+ numberOfPiDecimals := ((numerator digitLength - denominator digitLength) * 256 log) ceiling + 21.
+ twoPiFraction := (Fraction piAsFraction: numberOfPiDecimals) * 2.
+ ^ (self \\ twoPiFraction) asFloat.!
Item was added:
+ ----- Method: Fraction>>positive (in category 'testing') -----
+ positive
+
+ ^numerator positive!
Item was added:
+ ----- Method: Integer>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders."
+
+ ^self asFraction moduloTwoPiAsFloat!
Item was changed:
----- Method: Number>>cos (in category 'mathematical functions') -----
cos
+ "The receiver represents an angle measured in radians. Answer its cosine.
+ See comment at Fraction >> #moduloTwoPiAsFloat"
- "The receiver represents an angle measured in radians. Answer its cosine."
+ ^self moduloTwoPiAsFloat cos!
- ^self asFloat cos!
Item was added:
+ ----- Method: Number>>inMinusPiToPiRange (in category 'converting') -----
+ inMinusPiToPiRange
+ "Avoid conversion to Float if already ok"
+ (self > Float pi negated and: [self <= Float pi]) ifTrue: [
+ ^ self ].
+ ^ self moduloTwoPiAsFloat inMinusPiToPiRange!
Item was added:
+ ----- Method: Number>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders.
+ Note: Not to be implemented in the Float hierarchy. Only for exact number representations.
+ If receiver is ever a Float, sender should be using a Float specific operation."
+
+ ^self subclassResponsibility!
Item was changed:
----- Method: Number>>sin (in category 'mathematical functions') -----
sin
+ "The receiver represents an angle measured in radians. Answer its sine.
+ See comment at Fraction >> #moduloTwoPiAsFloat"
- "The receiver represents an angle measured in radians. Answer its sine."
+ ^self moduloTwoPiAsFloat sin!
- ^self asFloat sin!
Item was changed:
----- Method: Number>>tan (in category 'mathematical functions') -----
tan
"The receiver represents an angle measured in radians. Answer its
tangent."
+ ^self moduloTwoPiAsFloat tan!
- ^self asFloat tan!
David T. Lewis uploaded a new version of Kernel to project The Treated Inbox:
http://source.squeak.org/treated/Kernel-dtl.1571.mcz
==================== Summary ====================
Name: Kernel-dtl.1571
Author: dtl
Time: 1 June 2024, 8:17:40.334864 am
UUID: 2e9b69cf-6bba-4746-9f02-6ccae2d8eb82
Ancestors: Kernel-mt.1566
Initial load of 6350-sin-cos-ForHugeIntegersAndFractions-JuanVuletich-2024May07-15h42m-jmv.001.cs.st from Cuis from original commit:
commit 8a866980bb705135aae3299506a8d864dd2ac1e5
Author: Juan Vuletich <juan(a)jvuletich.org>
Date: Tue May 7 15:46:44 2024 -0300
Correct behavior for #sin, #cos, #tan for huge Integers and Fractions.
=============== Diff against Kernel-mt.1566 ===============
Item was added:
+ ----- Method: Fraction class>>pi1000Digits (in category 'approximations') -----
+ pi1000Digits
+ "
+
+ Integer pi1000Digits asNumber
+ Integer pi1000Digits asNumber class
+ Integer pi1000Digits asNumber / (10 raisedToInteger: Integer pi1000Digits size - 1) :: asFloat
+ Integer pi1000Digits asNumber+1 / (10 raisedToInteger: Integer pi1000Digits size - 1) :: asFloat
+ "
+
+ ^'314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921
6420198' .!
Item was added:
+ ----- Method: Fraction class>>piAsFraction: (in category 'approximations') -----
+ piAsFraction: numberOfDecimals
+ "Answer a Fraction built with the first numberOfDigits decimal digits of Pi.
+ Note: It will always be less than the Real Pi. It is not a rounded version of Pi, but a truncated version of pi.
+ Fraction piAsFraction: 5
+ "
+ ^(Fraction piDigitsAsInteger: numberOfDecimals) / (10 raisedToInteger: numberOfDecimals)!
Item was added:
+ ----- Method: Fraction class>>piDigitsAsInteger: (in category 'approximations') -----
+ piDigitsAsInteger: numberOfDecimals
+ "Answer an integer number formed by the first numberOfDecimals+1 digits of pi.
+ If numberOfDecimals=2, answer 314.
+ If numberOfDecimals=4, answer 31415
+
+ Fraction piDigitsAsInteger: 2
+ Fraction piDigitsAsInteger: 4
+ "
+ | answer characterStream manyDigits |
+ manyDigits := self pi1000Digits.
+ numberOfDecimals < manyDigits size ifFalse: [
+ ^self error: 'Can not approximate pi with so many decimals' ].
+ characterStream := manyDigits readStream.
+ answer := characterStream next digitValue.
+ numberOfDecimals timesRepeat: [
+ answer := 10 * answer + characterStream next digitValue ].
+ ^answer!
Item was added:
+ ----- Method: Fraction>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Useful for periodic functions definded on Floats.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ Evaluate comments below and compare results.
+ See senders."
+ "
+ | bigNum |
+ bigNum := 1e22 + (10202/10000).
+ {'wrong!!'. bigNum asFloat sin. bigNum asFloat cos} print.
+ {'wrong!!'. (bigNum+1) asFloat sin. (bigNum+1) asFloat cos} print.
+ {'correct!!'. bigNum moduloTwoPiAsFloat sin. bigNum moduloTwoPiAsFloat cos} print.
+ {'correct!!'. (bigNum+1) moduloTwoPiAsFloat sin. (bigNum+1) moduloTwoPiAsFloat cos} print.
+ {'Reference:'. 0 sin. 0 cos} print.
+ {'Reference:'. 1 sin. 1 cos} print.
+ "
+ "
+ | bigNum |
+ bigNum := 1e500 - (282532 / 100000).
+ {'wrong!!'. bigNum asFloat sin. bigNum asFloat cos} print.
+ {'wrong!!'. (bigNum+1) asFloat sin. (bigNum+1) asFloat cos} print.
+ {'correct!!'. bigNum moduloTwoPiAsFloat sin. bigNum moduloTwoPiAsFloat cos} print.
+ {'correct!!'. (bigNum+1) moduloTwoPiAsFloat sin. (bigNum+1) moduloTwoPiAsFloat cos} print.
+ {'Reference:'. 0 sin. 0 cos} print.
+ {'Reference:'. 1 sin. 1 cos} print.
+ "
+ "
+ (1e22 \\ Float twoPi) print.
+ (1e22+1 \\ Float twoPi) print.
+ 1e22 moduloTwoPiAsFloat print.
+ (1e22+1) moduloTwoPiAsFloat print.
+ (1e500 \\ Float twoPi) print.
+ (1e500+1 \\ Float twoPi) print.
+ 1e500 moduloTwoPiAsFloat print.
+ (1e500+1) moduloTwoPiAsFloat print.
+ "
+
+ | numberOfPiDecimals twoPiFraction |
+ (self positive and: [ self <= (628/100) ]) ifTrue: [
+ ^self asFloat ].
+ numberOfPiDecimals := ((numerator digitLength - denominator digitLength) * 256 log) ceiling + 21.
+ twoPiFraction := (Fraction piAsFraction: numberOfPiDecimals) * 2.
+ ^ (self \\ twoPiFraction) asFloat.!
Item was added:
+ ----- Method: Fraction>>positive (in category 'testing') -----
+ positive
+
+ ^numerator positive!
Item was added:
+ ----- Method: Integer>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders."
+
+ ^self asFraction moduloTwoPiAsFloat!
Item was changed:
----- Method: Number>>cos (in category 'mathematical functions') -----
cos
+ "The receiver represents an angle measured in radians. Answer its cosine.
+ See comment at Fraction >> #moduloTwoPiAsFloat"
- "The receiver represents an angle measured in radians. Answer its cosine."
+ ^self moduloTwoPiAsFloat cos!
- ^self asFloat cos!
Item was added:
+ ----- Method: Number>>inMinusPiToPiRange (in category 'converting') -----
+ inMinusPiToPiRange
+ "Avoid conversion to Float if already ok"
+ (self > Float pi negated and: [self <= Float pi]) ifTrue: [
+ ^ self ].
+ ^ self moduloTwoPiAsFloat inMinusPiToPiRange!
Item was added:
+ ----- Method: Number>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders.
+ Note: Not to be implemented in the Float hierarchy. Only for exact number representations.
+ If receiver is ever a Float, sender should be using a Float specific operation."
+
+ ^self subclassResponsibility!
Item was changed:
----- Method: Number>>sin (in category 'mathematical functions') -----
sin
+ "The receiver represents an angle measured in radians. Answer its sine.
+ See comment at Fraction >> #moduloTwoPiAsFloat"
- "The receiver represents an angle measured in radians. Answer its sine."
+ ^self moduloTwoPiAsFloat sin!
- ^self asFloat sin!
Item was changed:
----- Method: Number>>tan (in category 'mathematical functions') -----
tan
"The receiver represents an angle measured in radians. Answer its
tangent."
+ ^self moduloTwoPiAsFloat tan!
- ^self asFloat tan!
David T. Lewis uploaded a new version of Kernel to project The Treated Inbox:
http://source.squeak.org/treated/Kernel-dtl.1572.mcz
==================== Summary ====================
Name: Kernel-dtl.1572
Author: dtl
Time: 1 June 2024, 8:20:16.856257 am
UUID: f800d569-b687-4b52-922f-538d97b7f425
Ancestors: Kernel-dtl.1571
Adapt 6350-sin-cos-ForHugeIntegersAndFractions-JuanVuletich-2024May07-15h42m-jmv.001.cs.st from Cuis to Squeak
=============== Diff against Kernel-mt.1566 ===============
Item was added:
+ ----- Method: Fraction class>>pi1000Digits (in category 'approximations') -----
+ pi1000Digits
+ "
+
+ Integer pi1000Digits asNumber
+ Integer pi1000Digits asNumber class
+ Integer pi1000Digits asNumber / (10 raisedToInteger: Integer pi1000Digits size - 1) :: asFloat
+ Integer pi1000Digits asNumber+1 / (10 raisedToInteger: Integer pi1000Digits size - 1) :: asFloat
+ "
+
+ ^'314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921
6420198' .!
Item was added:
+ ----- Method: Fraction class>>piAsFraction: (in category 'approximations') -----
+ piAsFraction: numberOfDecimals
+ "Answer a Fraction built with the first numberOfDigits decimal digits of Pi.
+ Note: It will always be less than the Real Pi. It is not a rounded version of Pi, but a truncated version of pi.
+ Fraction piAsFraction: 5
+ "
+ ^(Fraction piDigitsAsInteger: numberOfDecimals) / (10 raisedToInteger: numberOfDecimals)!
Item was added:
+ ----- Method: Fraction class>>piDigitsAsInteger: (in category 'approximations') -----
+ piDigitsAsInteger: numberOfDecimals
+ "Answer an integer number formed by the first numberOfDecimals+1 digits of pi.
+ If numberOfDecimals=2, answer 314.
+ If numberOfDecimals=4, answer 31415
+
+ Fraction piDigitsAsInteger: 2
+ Fraction piDigitsAsInteger: 4
+ "
+ | answer characterStream manyDigits |
+ manyDigits := self pi1000Digits.
+ numberOfDecimals < manyDigits size ifFalse: [
+ ^self error: 'Can not approximate pi with so many decimals' ].
+ characterStream := manyDigits readStream.
+ answer := characterStream next digitValue.
+ numberOfDecimals timesRepeat: [
+ answer := 10 * answer + characterStream next digitValue ].
+ ^answer!
Item was added:
+ ----- Method: Fraction>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Useful for periodic functions definded on Floats.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ Evaluate comments below and compare results.
+ See senders."
+ "
+ | bigNum |
+ bigNum := 1e22 + (10202/10000).
+ {'wrong!!'. bigNum asFloat sin. bigNum asFloat cos} print.
+ {'wrong!!'. (bigNum+1) asFloat sin. (bigNum+1) asFloat cos} print.
+ {'correct!!'. bigNum moduloTwoPiAsFloat sin. bigNum moduloTwoPiAsFloat cos} print.
+ {'correct!!'. (bigNum+1) moduloTwoPiAsFloat sin. (bigNum+1) moduloTwoPiAsFloat cos} print.
+ {'Reference:'. 0 sin. 0 cos} print.
+ {'Reference:'. 1 sin. 1 cos} print.
+ "
+ "
+ | bigNum |
+ bigNum := 1e500 - (282532 / 100000).
+ {'wrong!!'. bigNum asFloat sin. bigNum asFloat cos} print.
+ {'wrong!!'. (bigNum+1) asFloat sin. (bigNum+1) asFloat cos} print.
+ {'correct!!'. bigNum moduloTwoPiAsFloat sin. bigNum moduloTwoPiAsFloat cos} print.
+ {'correct!!'. (bigNum+1) moduloTwoPiAsFloat sin. (bigNum+1) moduloTwoPiAsFloat cos} print.
+ {'Reference:'. 0 sin. 0 cos} print.
+ {'Reference:'. 1 sin. 1 cos} print.
+ "
+ "
+ (1e22 \\ Float twoPi) print.
+ (1e22+1 \\ Float twoPi) print.
+ 1e22 moduloTwoPiAsFloat print.
+ (1e22+1) moduloTwoPiAsFloat print.
+ (1e500 \\ Float twoPi) print.
+ (1e500+1 \\ Float twoPi) print.
+ 1e500 moduloTwoPiAsFloat print.
+ (1e500+1) moduloTwoPiAsFloat print.
+ "
+
+ | numberOfPiDecimals twoPiFraction |
+ (self positive and: [ self <= (628/100) ]) ifTrue: [
+ ^self asFloat ].
+ numberOfPiDecimals := ((numerator digitLength - denominator digitLength) * 256 log) ceiling + 21.
+ twoPiFraction := (Fraction piAsFraction: numberOfPiDecimals) * 2.
+ ^ (self \\ twoPiFraction) asFloat.!
Item was added:
+ ----- Method: Fraction>>positive (in category 'testing') -----
+ positive
+
+ ^numerator positive!
Item was added:
+ ----- Method: Integer>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders."
+
+ ^(Fraction numerator: self denominator: 1) moduloTwoPiAsFloat!
Item was changed:
----- Method: Number>>cos (in category 'mathematical functions') -----
cos
+ "The receiver represents an angle measured in radians. Answer its cosine.
+ See comment at Fraction >> #moduloTwoPiAsFloat"
- "The receiver represents an angle measured in radians. Answer its cosine."
+ ^self moduloTwoPiAsFloat cos!
- ^self asFloat cos!
Item was added:
+ ----- Method: Number>>inMinusPiToPiRange (in category 'converting') -----
+ inMinusPiToPiRange
+ "Avoid conversion to Float if already ok"
+ (self > Float pi negated and: [self <= Float pi]) ifTrue: [
+ ^ self ].
+ ^ self moduloTwoPiAsFloat inMinusPiToPiRange!
Item was added:
+ ----- Method: Number>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders.
+ Note: Not to be implemented in the Float hierarchy. Only for exact number representations.
+ If receiver is ever a Float, sender should be using a Float specific operation."
+
+ ^self subclassResponsibility!
Item was changed:
----- Method: Number>>sin (in category 'mathematical functions') -----
sin
+ "The receiver represents an angle measured in radians. Answer its sine.
+ See comment at Fraction >> #moduloTwoPiAsFloat"
- "The receiver represents an angle measured in radians. Answer its sine."
+ ^self moduloTwoPiAsFloat sin!
- ^self asFloat sin!
Item was changed:
----- Method: Number>>tan (in category 'mathematical functions') -----
tan
"The receiver represents an angle measured in radians. Answer its
tangent."
+ ^self moduloTwoPiAsFloat tan!
- ^self asFloat tan!
Item was added:
+ ----- Method: ScaledDecimal>>moduloTwoPiAsFloat (in category 'converting') -----
+ moduloTwoPiAsFloat
+ "Answer the remainder of the division by 2 * pi, as a Floating Point number.
+ Provides full Float precision of the remainder result, even for huge arguments.
+ See comment at Fraction.
+ See senders."
+
+
+ ^ self asFraction moduloTwoPiAsFloat!