Hello, I was trying to return the previous setting instead of Void for the different outputting routines in Float (outputFixed, outputGeneral and outputFloating), so I looked more carefully at this issue.
Issue #159 => https://github.com/fricas/fricas/issues/159 Basically, and more spectacularly that what was expressed in the issue #159: (1) -> float(17,-1) (1) 9.0 (2) -> %*2 (2) 17.0 (3) -> float(17,-1,2) (3) 8.5 Adding PRINT()$Lisp to the two 'float' routines (two or three args) I saw the difference that leads to this: (27) -> float(17,-1) (17 . -1) (27) 9.0 (28) -> float(17,-1,2) (156797324626531188736 . -64) (28) 8.5 And to coerce the Float to OutputForm convert(Float)@String is used. But with default settings the bits(n)$Float routine is used to change the precision in bits before performing the transformation to a string and it uses the mantissa which is for 8.5 (17 . -1) only 5 bits So when internal output routines do the string coercion digits() returns 1, this explains the rounding done above: (6) -> )tr Float )ops bits digits Packages traced: Float Parameterized constructors traced: FLOAT (6) -> float(17,-1) 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,60 : 5 1>exit Float.bits,60 : 68 1<enter Float.digits,91 : 1<enter Float.bits,49 : 1>exit Float.bits,49 : 5 1>exit Float.digits,91 : 1 1<enter Float.bits,49 : 1>exit Float.bits,49 : 5 1<enter Float.bits,60 : 68 1>exit Float.bits,60 : 5 (6) 9.0 Type: Float (7) -> %*2 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 1<enter Float.bits,49 : 1>exit Float.bits,49 : 68 [snip] (7) 17.0 ====================== I do not know how that should be solved (output routines or the convert(Float)@String) but removing the use of 'b' below i.e. don't touch the precision in bits avoids this easily and show that this precision modification is not adapted to all Float representations. convert(f) : S == b : Integer := OUTPREC = -1 and not zero? f => bits(length(abs mantissa f)::PositiveInteger) 0 s := OUTMODE = "fixed" => fixed f OUTMODE = "floating" => floating f OUTMODE = "general" => general f empty()$String if b > 0 then bits(b::PositiveInteger) s = empty()$String => error "bad output mode" s ============================= Another point: It is possible to modify some parameters to Float output routines, what about returning the previous settings? For example outputSpacing(n) returns Void but if you want to temporarily modify this setting, in Spad for example, reverting to the user setting is not possible. I attached a proof of concept patch that implements this. In fact, even the macro 'separator ==> underscore()$Character' could also be parametrable, it is not in this diff though. - Greg -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/CAHnU2dbkR3iQzn%2BW4p%2BTyGDrqg9W%2B-cggBS%2BQ%2BjRGKBsRX6Xuw%40mail.gmail.com.
float.diff
Description: Binary data