Jump to content



How To Change To Decimal?


  • Please log in to reply
14 replies to this topic

#1 Guest_Tom_*

Guest_Tom_*
  • Guests

Posted 11 November 2005 - 11:56 AM

:cry:

Why when I try cas.fround(34.567831,4) it always returns natural number?? What should I do to get decimal????

#2 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 11 November 2005 - 12:09 PM

Actually it should return a CAS expression with value "345678/10000"... It works correctly on my CP :huh:

#3 Guest_Guest_*

Guest_Guest_*
  • Guests

Posted 11 November 2005 - 12:11 PM

Actually it should return a CAS expression with value "345678/10000"... It works correctly on my CP :huh:


But how to change "345678/10000" format to format with dot?

#4 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 11 November 2005 - 12:44 PM

There is no function to do that yet :(
But don't worry it will be available in the next releases ;)

Edited by Orwell, 11 November 2005 - 12:48 PM.


#5 Guest_Guest_*

Guest_Guest_*
  • Guests

Posted 11 November 2005 - 02:53 PM

There is no function to do that yet :(
But don't worry it will be available in the next releases ;)

:cry:

#6 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 11 November 2005 - 03:05 PM

There is no function to do that yet :(
But don't worry it will be available in the next releases ;)

Hmmm, Orwell it seems that you are quite busy indeed. You can convert a CAS result to a numerical value by treating it as a CAS function:
foo=cas.fround(34.567831,3)
makes foo a "userdata" variable equal to 172839/5000, but
foo(0)
is a "number" variable equal to 34.5678. You can even assign that variable to foo directly:
foo=cas.fround(34.567831,3)(0)
will make foo a number variable.
In general, if foo is a CAS numerical result, it can be converted to a CPLua "number" variable by issuing foo(any number). It seems that this is a side-effect of the way that CAS functions can be used in CPLua, but it works, provided that the CAS result is not in exponential form (see my bug report for that).

#7 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 11 November 2005 - 06:15 PM

That's right, I didn't think about that actually :)
But I think that something like 'cas.tonumber' or 'cas.evaluate' would be better :unsure:

#8 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 11 November 2005 - 06:25 PM

But I think that something like 'cas.tonumber' or 'cas.evaluate' would be better :unsure:

Indeed, such a function will make things much clearer. "cas.evaluate" seems a very good name for this function. If I remeber well, Kilburn asked something similar to Tom's question a few days ago. It is currently not clear to most CPLua users that <CAS expression>(0) does the right thing.
However, the current way to evaluate a CAS expression works, and I extensively use it in the project I'm working these days. If you are planning to change the current behavior, let me know...

#9 Guest_Tom_*

Guest_Tom_*
  • Guests

Posted 12 November 2005 - 01:20 PM

Hmmm, Orwell it seems that you are quite busy indeed. You can convert a CAS result to a numerical value by treating it as a CAS function:

foo=cas.fround(34.567831,3)
makes foo a "userdata" variable equal to 172839/5000, but
foo(0)
is a "number" variable equal to 34.5678. You can even assign that variable to foo directly:
foo=cas.fround(34.567831,3)(0)
will make foo a number variable.
In general, if foo is a CAS numerical result, it can be converted to a CPLua "number" variable by issuing foo(any number). It seems that this is a side-effect of the way that CAS functions can be used in CPLua, but it works, provided that the CAS result is not in exponential form (see my bug report for that).


Tihis is it!! Thank You!!!
:)

#10 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 12 November 2005 - 06:16 PM

Tihis is it!! Thank You!!!
:)

Solving CPLua programming problems is always a pleasure. :)

#11 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 12 November 2005 - 06:18 PM

Cool, now I can introduce any bug I want since it will be a pleasure to solve them :P

#12 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 12 November 2005 - 07:27 PM

Cool, now I can introduce any bug I want since it will be a pleasure to solve them :P

Nooo, I didn't said that solving bugs is a pleasure. I said that I like solving programming problems, not bugs :P. Thanks for your "offer", but I don't want more bugs... :P

#13 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 16 November 2005 - 08:51 PM

In the next CPLua version it will be possible to evaluate CAS expressions (to convert them into a simple number) in the same way, but without having to give a fake "zero" value in the parenthesis.
Thus,
x = cas("45/7")
x2 = x()
will create a number 'x2' with value 6.428... ;)

#14 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 16 November 2005 - 09:18 PM

In the next CPLua version it will be possible to evaluate CAS expressions (to convert them into a simple number) in the same way, but without having to give a fake "zero" value in the parenthesis.
Thus,

x = cas("45/7")
x2 = x()
will create a number 'x2' with value 6.428... ;)

Short, clear, functional. I like it. But what if you add a fake number anyway? For example, if you forgot to remove a zero (or any other number), needed in previous versions?

#15 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 16 November 2005 - 09:35 PM

The result will be the same than in previous versions, so this will be accepted too ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users