POV-Ray : Newsgroups : povray.general : INQUIRY: How to Get After-Period Value Server Time
1 Nov 2024 03:15:56 EDT (-0400)
  INQUIRY: How to Get After-Period Value (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Sven Littkowski
Subject: INQUIRY: How to Get After-Period Value
Date: 1 Apr 2018 01:16:11
Message: <5ac06b1b$1@news.povray.org>
Hi,

I have values like 7.23 or 19.59

and want to retrieve just the value after the period sign (23).
I am sure, POV-Ray has a function for that, but none of their names
rings my bells.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Stephen
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 1 Apr 2018 03:37:25
Message: <5ac08c35$1@news.povray.org>
On 01/04/2018 06:16, Sven Littkowski wrote:
> Hi,
> 
> I have values like 7.23 or 19.59
> 
> and want to retrieve just the value after the period sign (23).
> I am sure, POV-Ray has a function for that, but none of their names
> rings my bells.
> 

int() will return the numbers to the left of the decimal point. So 
subtract one from the other. And with any luck. There she is.



-- 

Regards
     Stephen


Post a reply to this message

From: Alain
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 1 Apr 2018 15:30:03
Message: <5ac1333b@news.povray.org>
Le 18-04-01 à 01:16, Sven Littkowski a écrit :
> Hi,
> 
> I have values like 7.23 or 19.59
> 
> and want to retrieve just the value after the period sign (23).
> I am sure, POV-Ray has a function for that, but none of their names
> rings my bells.
> 
> ---
> Diese E-Mail wurde von AVG auf Viren geprüft.
> http://www.avg.com
> 

Try something like this :

#declare Fractional = In_Value - int(In_Value);


Post a reply to this message

From: Kenneth
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 1 Apr 2018 18:40:00
Message: <web.5ac15dd036b91578a47873e10@news.povray.org>
Another interesting way to do it would be to use POV-Ray's built-in 'floor'
function:

#declare AAA = 7.23;

#declare REMAINDER = AAA - floor(AAA);

--- I'm kind of surprised that POV-Ray doesn't have a 'remainder' function
built-in. I looked in all of the documentation sections that I could think of,
but no luck. It would be a useful addition for the future ;-)


Post a reply to this message

From: Bald Eagle
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 2 Apr 2018 08:20:01
Message: <web.5ac21eeb36b91578c437ac910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:


mod(A,B) Value of A modulo B. Returns the remainder after the integer division
of A/B. Formula is mod=((A/B)-int(A/B))*B.

So, I'm guessing mod(A, 1) gives you the remainder.

((1.25/1) - 1) = 0.25, times 1 = 0.25


Post a reply to this message

From: Kenneth
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 2 Apr 2018 19:15:01
Message: <web.5ac2b85f36b91578a47873e10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
>
>
> mod(A,B) Value of A modulo B. Returns the remainder after the integer division
> of A/B. Formula is mod=((A/B)-int(A/B))*B.
>
> So, I'm guessing mod(A, 1) gives you the remainder.
>
> ((1.25/1) - 1) = 0.25, times 1 = 0.25

Yeah, mode(A,B) was as close as I could find to such a function... but I didn't
work it out. It looked... complicated :-P

Nice.


Post a reply to this message

From: Bald Eagle
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 2 Apr 2018 19:25:01
Message: <web.5ac2bb4036b915785cafe28e0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> Yeah, mode(A,B) was as close as I could find to such a function... but I didn't
> work it out. It looked... complicated :-P


I poked the bear once, and I learned.   ;)
http://news.povray.org/povray.newusers/thread/%3Cweb.51fb3b6e744b4afe73fc9ebb0%40news.povray.org%3E/

So now I remember as well as I can what mod(A, B) does.   :D


Post a reply to this message

From: Kenneth
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 2 Apr 2018 19:35:00
Message: <web.5ac2be0636b91578a47873e10@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

>
> Yeah, mode(A,B) was as close as I could find...

mode(A/B) ???  Er, I meant mod(A/B) . It's my keyboard's fault!!!! Uh,
naturally.


Post a reply to this message

From: Sven Littkowski
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 3 Apr 2018 05:52:48
Message: <5ac34ef0$1@news.povray.org>
Thanks, Stephen Alain and Kenneth.

And yes, a REMAINDER function would be useful as that would be the
direct road to get the value after the period sign (fractionals).

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: INQUIRY: How to Get After-Period Value
Date: 3 Apr 2018 05:57:59
Message: <5ac35027@news.povray.org>
I will use the formula of
"MyFractional = MyInitialValue - int(MyInitialValue)"

to convert time value fractionals (00..59) into decimal fractionals.
This will allow me to let the sun (light_source) wander over the sky
depending on the time value the user enters as value of MyTime.   :-)

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.