Hi Mark (aka Mark Probert [mailto:probertm@nortelnetworks.com]):

You enlightened last Wednesday, December 11, 2002 2:46 AM:

My own experience (based on developing real-time trading

systems for some merchant banks), is that the best solution

is to use scaled integers, to 100th of a cent. So, $154.34

–> 1543400. You then get very fast operations (they are all

integer operations) and, in general, well with ± 4 billion.

Ruby, with BigInt makes it trivial.

Hmmm… very clever/insightful, sir Mark. I’m putting your tip on my code

bank

C:\family\ruby>type a1.rb

def t

(2.4)/(0.2)

end

x = t

p x

p x.truncate

C:\family\ruby>ruby a1.rb

12

11

C:\family\ruby>type a1.rb

def t

(2.4*100)/(0.2*100)

end

x = t

p x

p x.truncate

C:\family\ruby>ruby a1.rb

12.0

12

I do not get truncation problems

Regards,

-mark.

Kind regards,

-botp

Hi, botp.

Hmmm… very clever/insightful, sir Mark. I’m putting your tip on my code

bank

Scaled integers can be very handy in lots of situations.

I guess that we have just got so used to having floating

point available that we forget about what we lose.

For example, using scaled integers you can represent 1/3,

something that you can’t do using (most) floating point

representations.

Interestingly, there are a bunch of rational approximations

for irrationals that allow you to do more “serious” math

using scaled integers:

const ratio error

pi 355/113 8.5e-8

sqrt(2) 19601/13860 1.5e-9

sqrt(3) 18817/10864 1.1e-9

e 28667/10564 5.5e-9

c 24559/8192 1.6e-9

I haven’t done any checks to see if this will make any difference

to Ruby’s performance.

Regards,

-mark.

## ···

At 10:25 AM 12/11/2002 +0900, you wrote:

Ah, but c is exactly 300,000 kilometers per second*, if you use metric,

its not a problem!

## ···

Mark Probert (probertm@nortelnetworks.com) wrote:

Interestingly, there are a bunch of rational approximations

for irrationals that allow you to do more “serious” math

using scaled integers:

const ratio error

pi 355/113 8.5e-8

sqrt(2) 19601/13860 1.5e-9

sqrt(3) 18817/10864 1.1e-9

e 28667/10564 5.5e-9

c 24559/8192 1.6e-9

–

Eric Hodel - drbrain@segment7.net - http://segment7.net

All messages signed with fingerprint:

FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Emmm, no

Speed of light in vacuum c = 1/sqrt(epsilon_0 * mu_0) =~ 2.997925 x 10^8 m.s^-1 (*)

It’s a very good approximation, though.

(*) S. Ramo, J.R. Whinnery, and T.V. Duzer, Fields and waves in

communication electronics, 3rd ed, 1994

Value recommended by National Academy of Sciences—National Research

Council Committee on Fundamental Constants in 1963.

You might find a better value, though but I’m staying w/ 3e8m.s^-1 for my

calcs.

## ···

On Thu, Dec 12, 2002 at 04:03:25AM +0900, Eric Hodel wrote:

Mark Probert (probertm@nortelnetworks.com) wrote:

Interestingly, there are a bunch of rational approximations

for irrationals that allow you to do more “serious” math

using scaled integers:

const ratio error

pi 355/113 8.5e-8

sqrt(2) 19601/13860 1.5e-9

sqrt(3) 18817/10864 1.1e-9

e 28667/10564 5.5e-9

c 24559/8192 1.6e-9

Ah, but c is exactly 300,000 kilometers per second*, if you use metric,

its not a problem!

–

_ _

__ __ *| |* ___ _ __ ___ __ _ _ __

’_ \ / `| __/ __| '_`

_ \ / *` | ’* \

*) | (*| | |__ \ | | | | | (*| | | | |*

*.__/ _*,|_*|**/*| || |*|_*,*|*| |_|

Running Debian GNU/Linux Sid (unstable)

batsman dot geo at yahoo dot com

We apologize for the inconvenience, but we’d still like yout to test out

this kernel.

– Linus Torvalds, announcing another kernel patch

Hello Eric,

Wednesday, December 11, 2002, 10:03:25 PM, you wrote:

Ah, but c is exactly 300,000 kilometers per second*, if you use metric,

its not a problem!

are you sure that light speed was be known 200 years ago?

## ···

–

Best regards,

Bulat mailto:bulatz@integ.ru

Actually, the meter has been redefined to be 1/299,792,458th of the

distance that light travels in a vacuun in 1 second. Thus, the speed of

light is exactly 299,792,458 m/s.

Thins brings up an interesting point. Originally, the second was defined

as the period of a pendulum with length 1m. If that’s still the

definition, then this would be circular.

I wonder if the second has also been redefined.

Daniel Carrera

Graduate Teaching Assistant. Math Dept.

University of Maryland. (301) 405-5137

Interestingly, there are a bunch of rational approximations

for irrationals that allow you to do more “serious” math

using scaled integers:

const ratio error

pi 355/113 8.5e-8

sqrt(2) 19601/13860 1.5e-9

sqrt(3) 18817/10864 1.1e-9

e 28667/10564 5.5e-9

c 24559/8192 1.6e-9

Ah, but c is exactly 300,000 kilometers per second*, if you use metric,

its not a problem!

Emmm, no

Speed of light in vacuum c = 1/sqrt(epsilon_0 * mu_0) =~ 2.997925 x

10^8 m.s^-1 (*)

## ···

On Thu, 12 Dec 2002, Mauricio Fernández wrote:

On Thu, Dec 12, 2002 at 04:03:25AM +0900, Eric Hodel wrote:

Mark Probert (probertm@nortelnetworks.com) wrote:

It’s a very good approximation, though.

(*) S. Ramo, J.R. Whinnery, and T.V. Duzer, Fields and waves in

communication electronics, 3rd ed, 1994

Value recommended by National Academy of Sciences—National Research

Council Committee on Fundamental Constants in 1963.

You might find a better value, though but I’m staying w/ 3e8m.s^-1 for my

calcs.

–

_ _

__ __ *| |* ___ _ __ ___ __ _ _ __

’_ \ / `| __/ __| '_`

_ \ / *` | ’*

*) | (*| | |__ \ | | | | | (*| | | | |*

*.__/ _*,|_*|**/*| || |*|_*,*|*| |_|

Running Debian GNU/Linux Sid (unstable)

batsman dot geo at yahoo dot com

We apologize for the inconvenience, but we’d still like yout to test out

this kernel.

– Linus Torvalds, announcing another kernel patch

Found that somewhere:

second (s): In the International System of Units (SI), the time interval

equal to 9,192,631,770 periods of the radiation corresponding to the

transition between the two hyperfine levels of the ground state of the

cesium-133 atom. (188)

But perhaps this is old now, in fact I used to believe that it was

defined in terms of the time an electromagnetic wave takes to travel

299,792,458m in a vacuum

BTW, the metric system RULEZ! }:->

The proof, that’s probably what matz uses

## ···

On Thu, Dec 12, 2002 at 09:54:08AM +0900, Daniel Carrera wrote:

Actually, the meter has been redefined to be 1/299,792,458th of the

distance that light travels in a vacuun in 1 second. Thus, the speed of

light is exactly 299,792,458 m/s.

Thins brings up an interesting point. Originally, the second was defined

as the period of a pendulum with length 1m. If that’s still the

definition, then this would be circular.

I wonder if the second has also been redefined.

–

_ _

__ __ *| |* ___ _ __ ___ __ _ _ __

’_ \ / `| __/ __| '_`

_ \ / *` | ’* \

*) | (*| | |__ \ | | | | | (*| | | | |*

*.__/ _*,|_*|**/*| || |*|_*,*|*| |_|

Running Debian GNU/Linux Sid (unstable)

batsman dot geo at yahoo dot com

abuse me. I’m so lame I sent a bug report to debian-devel-changes

– Seen on #Debian

I’m attempting to spawn a thread when a user clicks a

button. The thread makes a system call. If I don’t

do a thread.join immediately after, the app crashes

(unknown software exception). Does FXRuby not like it

when a child thread makes system calls? A thread in a

’standard’ Ruby app (without FXRuby) can make these

calls just fine.

Any ideas?

## ···

#---------------------------------------

require 'fox’

include Fox

class MyMainWindow < FXMainWindow

def initialize(app)

super(app, “Thread Test”)

```
#layout screen
button = FXButton.new(self, "Push me.")
button.connect(SEL_COMMAND, method(:onButton))
end
def create
super
show(PLACEMENT_SCREEN)
end
def onButton(sender, sel, item)
thread = Thread.new do
`cmd /C dir`
end
#thread.join
end
```

end

theApp = FXApp.new

theApp.init(ARGV)

myWindow = MyMainWindow.new(theApp)

theApp.create

theApp.run

But perhaps this is old now, in fact I used to believe that it was

defined in terms of the time an electromagnetic wave takes to travel

299,792,458m in a vacuum

Ha!

This would make some interesting definitions:

Speed of light ©: 299,792,458 meters per second.

Meter (m): 1/299,792,458th of the distance that light travels in 1

second.

Second (s): The time that light takes to travel 299,792,458 meters.

Daniel Carrera

Graduate Teaching Assistant. Math Dept.

University of Maryland. (301) 405-5137

## ···

BTW, the metric system RULEZ! }:->

http://www.matsushita.co.jp/corp/timecapsule/record/4_10.html

The proof, that’s probably what matz uses

–

_ _

__ __ *| |* ___ _ __ ___ __ _ _ __

’_ \ / `| __/ __| '_`

_ \ / *` | ’*

*) | (*| | |__ \ | | | | | (*| | | | |*

*.__/ _*,|_*|**/*| || |*|_*,*|*| |_|

Running Debian GNU/Linux Sid (unstable)

batsman dot geo at yahoo dot com

abuse me. I’m so lame I sent a bug report to debian-devel-changes

– Seen on #Debian

Well, we all know that one of them should be wrong, right? In this case

it is the last one (for example, see

http://physics.nist.gov/cuu/Units/second.html).

Regards,

Bill

## ···

Daniel Carrera dcarrera@math.umd.edu wrote:

Ha!

This would make some interesting definitions:

Speed of light ©: 299,792,458 meters per second.

Meter (m): 1/299,792,458th of the distance that light travels in 1

second.

Second (s): The time that light takes to travel 299,792,458 meters.

Jason Persampieri wrote:

I’m attempting to spawn a thread when a user clicks a

button. The thread makes a system call. If I don’t

do a thread.join immediately after, the app crashes

(unknown software exception). Does FXRuby not like it

when a child thread makes system calls? A thread in a

’standard’ Ruby app (without FXRuby) can make these

calls just fine.

Any ideas?

Which version of Ruby? If it’s Ruby 1.6.7, please try it under Ruby

1.7.3 to see if it works there.