Anonymous | Login | 01-17-2021 03:45 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | |||||||
0007099 | [Squeak] Kernel | feature | N/A | 06-17-08 22:01 | 06-23-08 20:10 | |||||||
Reporter | nicolas cellier | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | open | |||||||||
Status | new | Product Version | 3.10 | |||||||||
Summary | 0007099: [FEATURE] Integer>>sqrtTruncated and sqrtRounded | |||||||||||
Description |
It can be done in Integer arithmetic and implementation is fast. And it won't suffer any potential inexact arithmetic problem raised by Float conversion... That's why i prefer (x sqrtTruncated) to (x sqrt truncated)... |
|||||||||||
Additional Information | TODO: implement for rationals... | |||||||||||
Attached Files |
![]() ![]() ![]() ![]() ![]() |
|||||||||||
|
![]() |
|
(0012300 - 213 - 231 - 231 - 231 - 231 - 231) nicolas cellier 06-17-08 23:18 |
Wrong changeset handling... Integer-sqrtTruncated-Test-M7099.1.cs incorrectly includes/duplicates some methods from Integer-sqrtTruncated-M7099.1.cs That's why there is a Integer-sqrtTruncated-Test-M7099.2.cs |
(0012301 - 185 - 197 - 197 - 197 - 197 - 197) nicolas cellier 06-17-08 23:24 |
When i think of it, raising a FloatingPointException in an integer arithmetic method is not the nicest thing to do! This exception should better be renamed as an ArithmeticException. |
(0012302 - 247 - 307 - 307 - 307 - 307 - 307) nicolas cellier 06-18-08 00:24 edited on: 06-18-08 00:45 |
A good example of intermediate inexact arithmetic failure: | x | x := (1 bitShift: 53). self assert: (x + (1/2)) squared sqrtRounded = (x+1) fails if implemented asFloat sqrt rounded I provide hereafter a first Fraction implementation |
(0012307 - 490 - 682 - 1082 - 1082 - 1082 - 1082) nicolas cellier 06-23-08 20:10 |
Andres Valloud who initiated my answer at http://groups.google.am/group/comp.lang.smalltalk/browse_thread/thread/179b982ac8562ccf [^] has posted on his blog a simular solution (See http://blogten.blogspot.com/2008/06/update-on-sqrtrounded.html) [^] : sqrtRounded | x | x := (self * 4) sqrtTruncated. ^(x//2) + (x\\2) which can also be written (may be more efficiently) sqrtRounded | x | x := (self bitShift: 2) sqrtTruncated. ^(x bitShift: -1) + (x bitAnd: 1) |
Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
56 total queries executed. 32 unique queries executed. |