Float printString?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Float printString?

kuszi
Hello!

I've made a script to perform GRASS GIS operations automatically.
It was running for weeks nicely.

Today it emerged:

Object: 1 error: The program attempted to divide a number by zero
ZeroDivide(Exception)>>signal (ExcHandling.st:254)
SmallInteger(Number)>>zeroDivide (SysExcept.st:1386)
Fraction>>setNumerator:setDenominator: (Fraction.st:485)
Fraction class>>numerator:denominator: (Fraction.st:66)
Fraction>>raisedToInteger: (Fraction.st:510)
SmallInteger(Number)>>raisedToInteger: (Number.st:922)
FloatD(Float)>>printOn:special: (Float.st:525)
FloatD(Float)>>printOn: (Float.st:436)
*FloatD(Object)>>printString (Object.st:546)*
FloatD(Object)>>printStringIfNecessary (process_25.st:15)
optimized [] in UndefinedObject>>executeStatements (process_25.st:298)
Array(SequenceableCollection)>>do: (SeqCollect.st:826)
UndefinedObject>>executeStatements (process_25.st:212)

So, somehow float cannot print itself anymore.
Maybe there was an upgrade of *gst *in the background...






*GNU Smalltalk version 3.2.91-716884a[...]Using default kernel path:
/usr/share/smalltalk/kernelUsing default image path: /var/lib/smalltalk*
*OS:* Linux kuszidell 4.6.3-1-ARCH #1 SMP PREEMPT Fri Jun 24 21:19:13 CEST
2016 x86_64 GNU/Linux


Code:
Transcript showCr: 'Lejtés: ',quo printStringIfNecessary.

printStringifNecessaey is my wrapper for printString not to print extra '
for Strings...

I wouldn't dare to instpect and touch float code and this may reach others
as well...

thanks
Robert
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Float printString?

Holger Freyther

> On 06 Jul 2016, at 10:44, Robert Kuszinger <[hidden email]> wrote:
>
> Hello!
>
> I've made a script to perform GRASS GIS operations automatically.
> It was running for weeks nicely.
>
> Today it emerged:
>
> Object: 1 error: The program attempted to divide a number by zero



> ZeroDivide(Exception)>>signal (ExcHandling.st:254)
> SmallInteger(Number)>>zeroDivide (SysExcept.st:1386)
> Fraction>>setNumerator:setDenominator: (Fraction.st:485)
> Fraction class>>numerator:denominator: (Fraction.st:66)
> Fraction>>raisedToInteger: (Fraction.st:510)

so the denominator is 0? Can you use >>#inspect on your float to see what your float looks like?

holger
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Float printString?

kuszi
Dear Holger,

thanks for your comment.
The inspect is here, whatever it means..

An instance of FloatD
  [1]: 224
  [2]: 221
  [3]: 240
  [4]: 122
  [5]: 184
  [6]: 184
  [7]: 41
  [8]: 191

Instead of an inspect I checked the values in the calculation:

    quo := (endHeight-startHeight)/length.
    quo inspect.
    Transcript showCr: 'endHeight: ',endHeight printStringIfNecessary.
    Transcript showCr: 'startHeight: ',startHeight printStringIfNecessary.
    Transcript showCr: 'length: ',length printStringIfNecessary.
    Transcript showCr: 'Lejtés: ',quo printStringIfNecessary.       #<-----
error happens here



Printout:

endHeight: 99
startHeight: 110.0
length: 56053.86243369161
*<same error msg here>*

Calculating the same in bc

(99-110.0)/56053.86243369161
-.00019623982224262149


Best regards
Robert





2016-07-06 12:08 GMT+02:00 Holger Freyther <[hidden email]>:

>
> > On 06 Jul 2016, at 10:44, Robert Kuszinger <[hidden email]> wrote:
> >
> > Hello!
> >
> > I've made a script to perform GRASS GIS operations automatically.
> > It was running for weeks nicely.
> >
> > Today it emerged:
> >
> > Object: 1 error: The program attempted to divide a number by zero
>
>
>
> > ZeroDivide(Exception)>>signal (ExcHandling.st:254)
> > SmallInteger(Number)>>zeroDivide (SysExcept.st:1386)
> > Fraction>>setNumerator:setDenominator: (Fraction.st:485)
> > Fraction class>>numerator:denominator: (Fraction.st:66)
> > Fraction>>raisedToInteger: (Fraction.st:510)
>
> so the denominator is 0? Can you use >>#inspect on your float to see what
> your float looks like?
>
> holger
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Float printString?

Paolo Bonzini-2


On 06/07/2016 12:40, Robert Kuszinger wrote:

> Dear Holger,
>
> thanks for your comment.
> The inspect is here, whatever it means..
>
> An instance of FloatD
>   [1]: 224
>   [2]: 221
>   [3]: 240
>   [4]: 122
>   [5]: 184
>   [6]: 184
>   [7]: 41
>   [8]: 191

I cannot reproduce this:

st> (99-110.0)/56053.86243369161
-0.0001962398222426215
st> FloatD fromBytes: #[191 41 184 184 122 240 221 224]
-0.0001962399669268441
st> 2 raisedToInteger: (-0.00019623982224262149)  exponent - (-0.00019623982224262149) class precision + 1
1/36893488147419103232

(It's -65 not -67 by the way).

I agree with Holger, probably you're compiling without GMP.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk