Author Topic: TEXT to REAL..  (Read 2853 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
TEXT to REAL..
« on: November 11, 2005, 11:21:51 AM »
Sorry, I know I have posted something similar few days ago..

but I can find a way to have the precision of 8 digit after the point.
I have this...

(setq a "2.06112265" )

I need to transform to REAL...

(read a)  = 2.06112
(atof a)  = 2.06112

How can I get the precision...in REAL... :oops:

note: my LUPREC variable is set to 8

Keep smile...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: TEXT to REAL..
« Reply #1 on: November 11, 2005, 12:09:04 PM »
The value is only displayed truncated ... the value is correct in the variable .. to test it, try this:

Code: [Select]
(setq a "2.06112265")
!a
"2.06112265"
(setq b (distof a))
2.06112
!b
2.06112
(rtos b 2 8)
"2.06112265"
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Andrea

  • Water Moccasin
  • Posts: 2372
Re: TEXT to REAL..
« Reply #2 on: November 11, 2005, 01:14:38 PM »
The value is only displayed truncated ... the value is correct in the variable .. to test it, try this:

Code: [Select]
(setq a "2.06112265")
!a
"2.06112265"
(setq b (distof a))
2.06112
!b
2.06112
(rtos b 2 8)
"2.06112265"

thanks Keith..

but ho can I divide 1 by b ??
Keep smile...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: TEXT to REAL..
« Reply #3 on: November 11, 2005, 01:41:15 PM »
Code: [Select]
(setq c (/ 1.0 (distof b)))
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Andrea

  • Water Moccasin
  • Posts: 2372
Re: TEXT to REAL..
« Reply #4 on: November 11, 2005, 01:54:56 PM »
Code: [Select]
(setq c (/ 1.0 (distof b)))

Keith...

b is alraydy in REAL...I think you want write this..

Code: [Select]
(setq c (/ 1.0 b))
but the result is..
0.485172
and must be 0.485172486

also, if i write
Code: [Select]
(rtos c 2 8)I obtain this result..."0.48517249"

not better..

I need to do this..

(/ 1 "2.06112265")
to have the exact result....

"0.485172486"
Keep smile...

LE

  • Guest
Re: TEXT to REAL..
« Reply #5 on: November 11, 2005, 02:02:09 PM »
What are you doing [or trying to do] ?.... is that value going for an output?.... or is for an internal use?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: TEXT to REAL..
« Reply #6 on: November 11, 2005, 02:45:04 PM »
Quote from: Andrea
(/ 1 "2.06112265")
to have the exact result....
"0.485172486"
Andrea, the true value is stored in the variable. You may not 'see' it but, rest assured, the computer does. To verify this, set the precision that RTOS outputs to a higher value:
Code: [Select]
(setq c (/ 1.0 b))
0.485172

(rtos c 2 16)
"0.4851724859750583"

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: TEXT to REAL..
« Reply #7 on: November 11, 2005, 03:19:02 PM »
Andrea, Indeed you are correct, I had meant to use (distof a) instead.

16 is the smallest accuracy you can obtain in rtos, unless it has changed in recent versions ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Andrea

  • Water Moccasin
  • Posts: 2372
Re: TEXT to REAL..
« Reply #8 on: November 11, 2005, 04:27:55 PM »
OK....so if I understand....

Code: [Select]
(setq c (/ 1.0 b))
0.485172
is in fact 0.4851724859750583
but it do not showing me all right ?

to see all digit..i need to do..(rtos c 2 16)
ti have..."0.4851724859750583"

so the final result of this will be...
Code: [Select]
(setq d (rtos (/ 1.0 b) 2 16))
even b not showing all digit..
isn't it ?

thanks. :roll:
« Last Edit: November 11, 2005, 04:40:13 PM by Andrea »
Keep smile...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: TEXT to REAL..
« Reply #9 on: November 11, 2005, 04:47:21 PM »
exactly
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Andrea

  • Water Moccasin
  • Posts: 2372
Re: TEXT to REAL..
« Reply #10 on: November 14, 2005, 07:41:59 PM »
finally...

thanks... :lol:
Keep smile...