[Glorp-development] Re: FixedPoint>>glorpPrintSQLOn:
Status: Pre-Alpha
Brought to you by:
alan_knight,
anthonylander,
boris_popov,
cdegroot,
and 4 others
From: Alan K. <kn...@ac...> - 2002-01-13 20:24:42
|
Thanks. That may raise some portability issues both between databases and between Smalltalk dialects, so I'll have to check it out a bit before I put it in. Does anyone know anything about fixed-point printing portability issues? At 07:22 PM 1/13/2002 +0200, Andrei N.Sobchuck wrote: >I've added method FixedPoint>>glorpPrintSQLOn:. >It is equivalent to FixedPoint>>printOn: but >without string 'aStream nextPut: self class exponentCharacter' >and number is enclosed in " ' ". >"'" is required because Postgres converts to >numeric type strings but not floats. >(Numeric type in Postgres coresponds to FixedPoint in VW). > >FixedPoint>>glorpPrintSQLOn: aStream > | denom n quo rem | > aStream nextPut: $'. > denom := 10 ** scale. > n := numerator * denom + (denominator bitShift: -1) // denominator. > numerator < 0 > ifTrue: > [aStream nextPut: $-. > n := n negated]. > quo := n // denom. > rem := n \\ denom. > > quo printOn: aStream. > scale > 0 > ifTrue: > [aStream nextPut: $.. > scale timesRepeat: > [rem := rem*10. > aStream nextPut: (Character digitValue: rem//denom). > rem := rem \\ denom]]. > aStream nextPut: $'. -- Alan Knight [|], Cincom Smalltalk Development kn...@ac... ak...@ci... http://www.cincom.com/smalltalk |