<commit_before>//
// Copyright (c) 2017 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//
#include "CorLib.h"
#include "nanoPAL_NativeDouble.h"

#if !defined(NANOCLR_EMULATED_FLOATINGPOINT)
HRESULT Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    double val = stack.Arg0().NumericByRefConst().r8;
    CLR_UINT32 res = System::Double::CompareTo( d, val );

    stack.PushValue().SetInteger( res );

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsInfinity( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsNaN( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsNegativeInfinity( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsPositiveInfinity( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}
#else
HRESULT Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    CLR_INT64 left  = stack.Arg0().NumericByRef().s8;
    CLR_INT64 right = stack.Arg1().NumericByRef().s8;

    stack.SetResult_I4((left < right) ? -1 : (left > right) ? 1 : 0);

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    stack.SetResult_Boolean(false);

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    stack.SetResult_Boolean(false);

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    stack.SetResult_Boolean(false);

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    stack.SetResult_Boolean(false);

    NANOCLR_NOCLEANUP_NOLABEL();
}
#endif<commit_msg>Fix System.Double implementations for emulated floating point (#1486)<commit_after>//
// Copyright (c) 2017 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//
#include "CorLib.h"
#include "nanoPAL_NativeDouble.h"

#if !defined(NANOCLR_EMULATED_FLOATINGPOINT)

HRESULT Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    double val = stack.Arg0().NumericByRefConst().r8;
    CLR_UINT32 res = System::Double::CompareTo( d, val );

    stack.PushValue().SetInteger( res );

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsInfinity( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsNaN( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsNegativeInfinity( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    double d = stack.Arg0().NumericByRefConst().r8;
    bool res = System::Double::IsPositiveInfinity( d );

    stack.SetResult_Boolean( res );    

    NANOCLR_NOCLEANUP_NOLABEL();
}

#else

HRESULT Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    NANOCLR_HEADER();

    CLR_INT64 left  = stack.Arg0().NumericByRef().s8;
    CLR_INT64 right = stack.Arg1().NumericByRef().s8;

    stack.SetResult_I4((left < right) ? -1 : (left > right) ? 1 : 0);

    NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    stack.NotImplementedStub();
}

HRESULT Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    stack.NotImplementedStub();
}

HRESULT Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    stack.NotImplementedStub();
}

HRESULT Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8( CLR_RT_StackFrame& stack )
{
    stack.NotImplementedStub();
}

#endif
{'fraction_non_alphanumeric': 0.1044504995458674, 'fraction_numerical': 0.01392673327278232, 'mean_word_length': 5.334611697027804, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7142020', 'n_tokens_mistral': 2560, 'n_tokens_neox': 2460, 'n_words': 336}